android access folder using environment.getexternalstoragedirectory on device with only internal memory would return?

落爺英雄遲暮 提交于 2020-01-16 13:20:35

问题


im using this code to access a folder:

String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/somefolder";

on devices with sdcard this is ok, i don't have a device with only internal memory to test what happens, what would happen if this is executed on a device without sdcard? will it automatically set to the internal memory path? the user of the app would put this folder in the root of the available memory.

is there a way to get internal path?

is there a way to check both roots to see if this folder is present?


回答1:


There are a few different types of "internal" storage.

On the first few android devices they had internal storage which was the partition in which the OS, and the installed applications were stored. Modern devices continue to have this type of internal storage (now adays you'll see 1-2gb of this type of storage on the higher end devices). This storage area is inaccessible to the user (unless they are rooted).

The other type of "internal" storage is generally much larger in space, and is accessible by the user. This type of storage is usually found on devices that don't come with an SD card. As of now (june 2012) 8 or 16gb are the most common sizes for this type of storage I think.

So on a device with no SD card your method is going to return to you the path that leads to the second type of "internal" storage. In fact basically what has happened here is they've put that flash memory in the device and basically tricked the OS into seeing it the same way as an SD card, but without the option to unmount / remove.



来源:https://stackoverflow.com/questions/10870793/android-access-folder-using-environment-getexternalstoragedirectory-on-device-wi

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