Access files on internal and external storage

不打扰是莪最后的温柔 提交于 2019-12-08 00:29:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!