我正在编写一个从数码相机下载照片的应用程序。将它们保存到什么地方最合适?必须是外部存储,因为预计会有千兆字节的图像。
最佳答案
保存应该共享的文件
如果您想保存不特定于您的应用程序并且在卸载应用程序时不应删除的文件,请将它们保存到外部存储的公共(public)目录之一。这些目录位于外部存储的根目录,例如 Music/、Pictures/、Ringtones/等。
In API Level 8 or greater, use getExternalStoragePublicDirectory(), passing it the type of public directory you want, such as DIRECTORY_MUSIC, DIRECTORY_PICTURES, DIRECTORY_RINGTONES, or others. This method will create the appropriate directory if necessary. If you're using API Level 7 or lower, use getExternalStorageDirectory() to open a File that represents the root of the external storage, then save your shared files in one of the following directories:
Music/ - Media scanner classifies all media found here as user music.
Podcasts/ - Media scanner classifies all media found here as a podcast.
Ringtones/ - Media scanner classifies all media found here as a ringtone.
Alarms/ - Media scanner classifies all media found here as an alarm sound.
Notifications/ - Media scanner classifies all media found here as a notification sound.
Pictures/ - All photos (excluding those taken with the camera).
Movies/ - All movies (excluding those taken with the camcorder).
Download/ - Miscellaneous downloads.
关于Android:存储图像的默认位置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8268186/