• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Is there a Filesystem Hierarchy Standard for Android ?

marcelpaulo

Lurker
Linux and Unix-like operating systems follow the FHS to organize directories and files. Is there a similar standard for Android ?

I use an app called syncthing, which allows the user to export its configuration to a set of 3 files. The app doesn't need these files to run, they're just a configuration backup. Currently it exports the 3 files directly to /storage/emulated/0. I'm interested in choosing a standard directory to store these files.
 
/storage/emulated/0 is also known as /sdcard0 or /sdcard. That's the top directory of the user area of the internal storage.

Android has a linux-like directory structure, but it doesn't follow the FHS organisation. It has some elements, such as an /etc, /mnt, /proc and /sbin, but no /usr, /var, etc . If you install a root-capable file manager and have root access you can see for yourself what the hierarchy is.

Without root you will only have direct access to the area named above anyway (/sdcard, /sdcard0, /storage/emulated/0, whatever you want to call it), so it's really a matter of how you choose to organise things within that area.
 
Hey, thanks for the instant reply, @Hadron !

I installed app ES File Explorer and poked around to learn.

But I still can't make up my mind about a good, standard directory name for storing the exported configuration files from app syncthing. As I said, the app doesn't need these files in order to run: they're a just a backup of the configuration. Would you have any suggestions ?

For the moment, I'm using:

/storage/sdcard1/data/syncthing

but somehow this doesn't feel standard.
 
OK, /storage/sdcard1 just means "on the removable SD card". So the desktop analogy for that would be saving it to a removable device (usb stick, external hard drive), except that this is one you'll leave plugged in most of the time. So I don't think the standard goes as far as specifying a filestructure on those devices - I treat them like I would my own home directory, and choose what works for me (which generally means "what gives me the best chance of finding it again a few years later?"). So if /data/syncthing works for you then it's in practice as good as anything (it is actually a rough analogy to how the internal data are stored, in /data/data/<app-package-name>).

The places where Android does have a standard are for things like the apps themselves and their internal data, but those things are in an area you don't have access to without root (/data/app, /data/data). And of course the ROM, kernel, firmware etc, but again it doesn't give you direct access to that stuff by default.

Many apps on android store their sd-card data (if any) in a folder named after the app, but I think that's a common choice rather than a standard.
 
Last edited:
what gives me the best chance of finding it again a few years later?

Agreed. But then again, that's what filesystem standards are for, with the added benefit that they'll be documented somewhere. For desktops, you have freedesktop.org. If you adhere as best as possible to a published and widely adopted standard, chances are you'll easily find your files and directories a few years later. So, for instance, I might store my private scripts under ~/scripts, but I follow the standards, I'll use ~/bin, so that it extends neatly the /bin, /usr/bin, /usr/local/bin standard.

Specifically regarding the app syncthing, you're right, from my perspective as a user, /storage/sdcard1/data/syncthing is as good as any other directory, as long as it makes sense to me and allows me to remember it easily. But thinking from the app perspective, the goal would be to choose a directory so that:

  1. If the app is uninstalled, the directory is not deleted. So it doesn't make sense to store the this configuration backup files in /storage/emulated/o/Android/data/appname because this will be gone when the app is gone
  2. The name is intuitive enough so that the user can easily find it
 
it doesn't make sense to store the this configuration backup files in /storage/emulated/o/Android/data/appname because this will be gone when the app is gone

Most apps, certainly all the ones I've ever used, do not delete folders/data in user space when uninstalled, only their own files.

From my own pov, I keep all my own-generated data on external SD card, in folders named for the apps it relates to e.g. /App01, /App02 etc. It means I've more than twenty folders in the /sdcard1 root, some of which date back several years from previous devices, but I always know where to find things. :)
 
Most apps, certainly all the ones I've ever used, do not delete folders/data in user space when uninstalled, only their own files.

I stand corrected. Thanks ! Made a test to confirm: I have app Skitch installed, and it stores stuff in this folder:

/storage/emulated/0/Android/data/com.evernote.skitch

I uninstalled Skitch, and that directory was also deleted. Does that qualify as
folders/data in user space
? Or you're referring strictly to directories we, users, create ?

Making a parallel with GNU/Linux (I run Xubuntu 14.10 on my laptop), config files under /etc/ may be deleted when the app is uninstalled (depending on how you choose to uninstall it), but config files under the home directory are never deleted when the app is uninstalled. What would be the Android equivalent to these 2 locations for configuration files ? If /storage/emulated/0/Android/data/com.evernote.skitch was deleted when I uninstalled Skitch, I guess that qualifies /storage/emulated/0/Android/data to be like /etc, and my /storage/sdcard1/data/syncthing would qualify as a home config directory. Does that make sense ?

I keep all my own-generated data on external SD card, in folders named for the apps it relates to e.g. /App01, /App02 etc

Why don't you keep them all as subdirectories of, say, /storage/sdcard1/data, so that you can backup them in one single sweep ? That was my idea when I created /storage/sdcard1/data/syncthing: I define /storage/sdcard1/data as a syncthing shared folder, so that it's kept in sync with my laptop.

But then again, the question remains: if the app (syncthing, for this particular example) exposes an option to export its configuration, in which directory should it export its backup configuration files to, so that it's not deleted when the app ins uninstalled ?
 
Made a test to confirm: I have app Skitch installed, and it stores stuff in this folder:

/storage/emulated/0/Android/data/com.evernote.skitch

I uninstalled Skitch, and that directory was also deleted. Does that qualify as ? Or you're referring strictly to directories we, users, create ?

By "user space" I mean user-created data. Can you specify a different (user-defined) location for saved Skitch data? If not, I'm surprised that the app removes everything in that folder unilaterally - that's contrary to good practice.

Making a parallel with GNU/Linux (I run Xubuntu 14.10 on my laptop), config files under /etc/ may be deleted when the app is uninstalled (depending on how you choose to uninstall it), but config files under the home directory are never deleted when the app is uninstalled. What would be the Android equivalent to these 2 locations for configuration files ?

I'm not sure there is an exact equivalent, but /etc normally requires system permissions iirc.

If /storage/emulated/0/Android/data/com.evernote.skitch was deleted when I uninstalled Skitch, I guess that qualifies /storage/emulated/0/Android/data to be like /etc, and my /storage/sdcard1/data/syncthing would qualify as a home config directory. Does that make sense ?

Yes....and no. The Android kernel is Linux-based, but the OS itself isn't Linux, so direct one-to-one correlation is problematic.

Why don't you keep them all as subdirectories of, say, /storage/sdcard1/data, so that you can backup them in one single sweep ? That was my idea when I created /storage/sdcard1/data/syncthing: I define /storage/sdcard1/data as a syncthing shared folder, so that it's kept in sync with my laptop.

My own backup strategy doesn't require it. :)

the question remains: if the app (syncthing, for this particular example) exposes an option to export its configuration, in which directory should it export its backup configuration files to, so that it's not deleted when the app ins uninstalled ?

That's up to you. Provided you don't save the config to the app's own folder (/storage/emulated/0/Android/data/com.evernote.skitch) it won't be deleted.
 
Can you specify a different (user-defined) location for saved Skitch data? If not, I'm surprised that the app removes everything in that folder unilaterally - that's contrary to good practice.

I can see that its cache is stored under /storage/emulated/0/Android/data/com.evernote.skitch. The actual edited photos are stored in one of these:

/storage/emulated/0/Skitch
/storage/emulated/0/Pictures/Skitch


and these survive uninstall.

Thanks a lot, @Slug and @Hadron, for your knowledgeable, patient and swift answers !
 
Back
Top Bottom