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

前端 未结 3 808
北海茫月
北海茫月 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:30

    Just simply use this:

    String primary_sd = System.getenv("EXTERNAL_STORAGE");
    if(primary_sd != null)
        Log.i("EXTERNAL_STORAGE", primary_sd);
    String secondary_sd = System.getenv("SECONDARY_STORAGE");
    if(secondary_sd != null)
        Log.i("SECONDARY_STORAGE", secondary_sd)
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-08 06:36

    There is more information here: Droid Incredible storage mount points. It seems that Droid Incredible mounts its internal storage to /emmc, supposedly mounted r/w. It is not yet verified whether the WRITE_EXTERNAL_STORAGE permission is necessary in order to gain r/w access - I'm trying to get this information from Google Code

    I will probably solve this by allowing the user two options to store the data:

    1. SD-Card
    2. Droid Incredible-only Internal storage

    Edit: It seems that the WRITE_EXTERNAL_STORAGE permission is sufficient: according to droidForums both /sdcard and /emmc has the same GID of 1015.

    Edit2: According to Google Group Thread the Incredible returns /sdcard as the result value of Environment.getExternalStorageDirectory(). Therefore, the user needs to decide whether he wants to use /sdcard or /emmc. The auto-detection of Incredible may be based on existence of the /emmc path.

    0 讨论(0)
提交回复
热议问题