在安装了很多应用程序并自己构建了一些应用程序之后,我相信很多人都对此感到好奇。如果我查看我的 SD 卡,它看起来绝对可怕,而且很难找到属于我的用于将音乐/视频/图片放在不同应用程序的所有文件夹之间的文件夹。
这里是否有任何约定,我们,开发人员,应该尝试将他们的应用程序放入一个基本文件夹中,或者谷歌已经完全忘记了这一点?
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?
发布评论
评论(2)
来自参考:
应用程序不应直接使用此顶级目录,以避免污染用户的根命名空间。应用程序私有的任何文件都应放置在 Context.getExternalFilesDir,如果应用程序被卸载,系统将负责删除它。其他共享文件应放置在 获取ExternalStoragePublicDirectory(字符串)。
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).
我在我的应用程序中扩展了 Application 类并具有以下内容...
然后在 onCreate() (在应用程序中)...
这会自动创建 /mnt/sdcard/Android/data/com.mycompany.myApp/files 如果没有不存在。您可以向 getExternalFilesDir() 提供“null”以外的其他参数,以获取图片、视频等内容。
I extend the Application class in my app and have the following...
Then in onCreate() (in the Application)...
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.