This has come up a few times, but it's still not quite clear how to
deal with this in a portable, forward compatible way. The question is
how to deal with images (media) that is stored on the phone's storage
and possibly on a sd-card as well.
This code below shows what i found out:
==========================
Cursor cur;
String[] projection = new String[]
{ MediaStore.Images.ImageColumns.DATA };
cur = MediaStore.Images.Media.query(getContentResolver(),
MediaStore.Images.Media.getContentUri("phoneStorage"),
projection);
File phoneStorageMount = new File("/emmc");
boolean phoneStorageMounted = (cur != null);
if (cur != null) cur.close();
cur = MediaStore.Images.Media.query(getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection);
boolean externalStorageMounted = (cur != null);
File externalMount = Environment.getExternalStorageDirectory();
if (cur != null) cur.close();
===========================
If the phone-storage is mounted, phoneStorageMounted is true. When
querying 'cur', you'll find that the root-directory (mount) of the
phone-storage is "/emmc".
If the external storage is mounted, externalStorageMounted is true.
The root-directory can be obtained in a compatible way using
Envirionment.getExternalStorageDirectory().
If you replace EXTERNAL_CONTENT_URI with INTERNAL_CONTENT_URI, you'll
find that the HTC Desire returns a proper cursor with a number of
rows. It points to images stored in the directory "/system/customize/
resource". But you can't insert or modify anything in this directory.
It is all read-only.
My questions are:
- If phoneStorageMounted, is it safe to assume that the root/mount-
directory is always "/emmc"?
- Is it safe to assume that INTERNAL_CONTENT_URI is never phone-
storage and read-only?
Can a google or HTC engineer chime in on this?
Thanks! :-)
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en