Programmatically accessing internal storage (not SD card) on Verizon HTC Droid Incredible (Android)

前端 未结 3 804
北海茫月
北海茫月 2021-02-08 05:58

I\'m trying to find information on how to programmatically access the HTC Droid Incredible\'s supposed 8GB of Internal Storage M

3条回答
  •  生来不讨喜
    2021-02-08 06:33

    As you're aware access to internal storage is usually limited to certain directories for each application by permissions. This is to stop one application reading data from another and from accessing system files without using the APIs. This makes sense since, for example, if you had an internet banking application you wouldn't want other apps to be able to access any of its cached data.

    Each application gets to store data in a directory under /data/data. However, normally you don't specify the paths explicitly but used methods like Context.openFileOutput() which creates the file in the appropriate subdirectory of your application's directly.

    I agree with you that it is unlikely that the majority of the 8GB of the Incredible's storage will be used for the /data partition.

    So if they are going to have a separate partition to allow music and photos to be stored easily on the phone's internal storage then they will have to do it in a way that's compatible with existing applications. This means using Environment.getExternalStorageDirectory() but since the Incredible also supports SD cards then you're right in that it's not obvious how this might work.

    There is a thread on the Android Developers Google Group discussing this exact question. Whilst there isn't an answer (at the time of writing) for how the Incredible works there's a post which says the Samsung Galaxy solves the same problem in this way:

    • The internal storage is mounted at /sdcard
    • If an SD card is also available this can be found at /sdcard/sd

    This seems a sensible solution since it will be compatible with existing applications, including those which have mistakenly hard coded /sdcard instead of using Environment.getExternalStorageDirectory().

    So my advice would be to use Environment.getExternalStorageDirectory() when you're looking for large areas for storage - either SD card or internal to the phone - and hope that each phone returns something sensible.

提交回复
热议问题