Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

To determine the External Storage (SD Card) Location, I'm using the command:

android.os.Environment.getExternalStorageDirectory().

I've not been able to find any corollary for Internal phone Storage.

In examining HTC/Google Nexus One, Motorola Droid, and HTC Dream/G1 phones, there (as would be expected) does not appear to be any Mount Point for such Arbitrary Internal Storage.

On these phones the Internal Storage is divided amongst /data, /system, and /cache partitions.

The Incredible's Internal Storage is certainly not going to be located in /system. /cache is also unlikely given that it is globally non-readable/non-executable.

I'd read in reviews that the phone will still be limited to 512MB or so for apps, suggesting that it is not simply a subdirectory of /data.

I do not have access to a Droid Incredible unit myself, of course.

like image 375
tliebeck Avatar asked Apr 20 '10 07:04

tliebeck


2 Answers

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.

like image 81
Martin Vysny Avatar answered Oct 31 '22 08:10

Martin Vysny


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.

like image 43
Dave Webb Avatar answered Oct 31 '22 08:10

Dave Webb