简体   繁体   中英

Is There Any Convention for Android SD Card Storage?

After installing a lot of apps, and building a few myself, I'm sure many people have been wondering about this. If I'm looking through my SD card it looks absolutely horrible, and its really hard to find folders that are mine for putting music/videos/pictures in between all the folders for different applications.

Is there any conventions here that we, the developers, should try to put their apps into one base folder or has Google forgot about this completely?

From reference :

Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir , which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory (String).

I extend the Application class in my app and have the following...

protected static File myAppDir = null;

Then in onCreate() (in the Application)...

if (myAppDir == null)
    myAppDir = new File(getExternalFilesDir(null).getAbsolutePath());

This automatically creates /mnt/sdcard/Android/data/com.mycompany.myApp/files if it doesn't exist. You can supply other parameters than 'null' to getExternalFilesDir() for things like pictures, videos etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM