Monday, July 24, 2017

Get Android Apps to See External Storage


How to Get Android Apps to See External Storage on Chromebooks


Android apps are a great way to expand the sometimes limited capabilities of Chromebooks, but they can be a problem if you store most of your data on an external medium—like an SD card, for example.
Fortunately, with a few commands you can actually “force” Android apps to not only see external storage, but write to it as well. I will warn you, though: this does require a few shell commands, so if you’re not comfortable with that, tread carefully. Shout out to Nolirium for this incredibly helpful blog post that that got me rolling with this. Thanks to the guidance found there, I was able to get this this working without issue.

So, How Does This Work?

In short, we’ll be using bind mounts to basically “tether” a folder on the external medium to one that’s part of the internal file structure. Basically, this allows Android see the contents of the external folder, because it’s linked to a folder on the internal storage, which it can see without problems.
It’s worth noting that binding these folders will only work in Android—it won’t affect how Chrome OS sees the folders or the files within. We’re going to create a folder called “Bound” in the root of the Downloads directory in Chrome OS and bind a folder on the external medium to this folder, and while Android will see the contents of the external folder in the Bound directory, Chrome OS will not—the Bound directly will look completely empty. But since Chrome OS can natively interact with external storage, this shouldn’t be an issue.

Step One: Create Your Folders

With that, we’re ready to create the directories that we’ll use for this. Like I said above, we’re going to create a folder in the Downloads directory called “Bound.” So go ahead and open the Chrome OS Files app, and navigate to the Downloads directory.
From there, right click and choose “New Folder.”
Name this folder “Bound.”
It’s worth noting that can name this whatever you like, but for the purposes of this tutorial and the commands you’ll use below, we’re using “Bound.”
If you have a specific set of files you want Android to be able to see on your Chromebook, go ahead and navigate to your external medium and create a new folder here, too. Name it accordingly—I’m using “Screenshots” for this example, so feel free to change it if it doesn’t make sense for your application. Just remember that you’ll have to change part of the commands below to reflect your folder name.

Step Two: Open a Root Shell and Create the Bind

First, you’re going to need to open a Crosh window by pressing Ctrl+Alt+T on your keyboard. A new, solid black window will open in your browser. Alternatively, you can install the Crosh Window app from the Chrome App Store (which also requires the Secure Shell app to be installed), but that’s not necessary if it’s something you don’t think you’ll use often.
In the Crosh window, type the following:
shell
Followed by:
sudo su
It will ask for your password—this should be the same one you sign into your Chromebook with.
At this point, you’re in a root shell, which is what we want. The following commands should give you read/write access to the external folder directly from Android apps. For the purposes of this tutorial, I’m going to break them down one at at time, but keep in mind that you can string them together if you’d like—just separate each command with && symbols.
Note: The default title for an external drive in Chrome OS is “UNTITLED.” If your drive has been named something else, use that in place of “UNTITLED” in the following commands.
With that out of the way, enter the following into the root shell window:
mount --bind /media/removable/UNTITLED/Screenshots /run/arc/sdcard/default/emulated/0/Download/Bound

mount --bind /media/removable/UNTITLED/Screenshots /run/arc/sdcard/read/emulated/0/Download/Bound

mount --bind /media/removable/UNTITLED/Screenshots /run/arc/sdcard/write/emulated/0/Download/Bound
Again, change the name of the external folder to whatever you chose if it’s different than mine.

Step Three: Profit

That’s pretty much all there is to it. Like I said earlier, this won’t affect the way Chrome OS sees your folders, only Android.
Of course, it’s not a perfect system. Some Android apps may be able to see the contents of the bound folder, but not interact with them. For example, I use Skitch for annotating screenshots, and while it can see everything in the bound folder, it’s unable to open any of the files. This is probably in large part to do with the fact that Skitch is no longer in active development so it’s quite outdated, but it’s still a good example of how imperfect this system can be.
Also, this bind will not survive a reboot. So each time you reboot the computer, you’ll have to re-enter the above commands. I’ve also seen where some users have lost access to the bound folder after the system goes into sleep mode, but I haven’t personally had this issue. As with most workarounds like this one, your mileage may vary.



PicSayPro showing the contents of the Bound folder.

Of course, Google is actively working on enabling SD card contents to Android apps, so eventually we should get proper support. But until that point, this is the next best thing.

No comments:

Post a Comment