问题
I have an Xperia Neo V that does not have any internal storage - only an SD card as external storage, while the Galaxy S3 has both internal and external storage.
When using this function Environment.getExternalStorageDirectory();
I can access files only on internal storage(S3) but there is no problem with Xperia Neo V.
How can I access files on both internal and external storage?
回答1:
I have an Xperia Neo V that does not have any internal storage
All Android devices have internal storage, including the Xperia Neo V. Internal storage is where the OS and application data is stored -- without it, your phone would not work.
Presumably, you are having problems with the words "external" and "removable". In Android terms, "external" means "can be accessed by the user independently by plugging a USB cable between the device and a host computer". All Android devices have external storage; whether that storage is removable or not varies.
So, in the case of an Xperia Neo V, you have both internal and external storage, and the external storage is represented by a removable SD card.
When using this function Environment.getExternalStorageDirectory(); I can access files only on internal storage(S3) but there is no problem with Xperia Neo V.
That is because getExternalStorageDirectory()
returns the external storage directory for that device.
How can I access files on both internal and external storage?
Use getExternalStorageDirectory()
to get access to external storage. Use getFilesDir()
to get at your app's portion of internal storage.
For devices that have multiple forms of external storage -- such as your Galaxy S3 -- the Android SDK only supports accessing whichever one of those is provided by getExternalStorageDirectory()
.
来源:https://stackoverflow.com/questions/13097466/access-files-on-internal-and-external-storage