Best I've found is to look at the device model and see if it's the Incredible or Galaxy. If it is, then use /emmc or /sdcard/sd as a special case, otherwise use getExternalStorageDirectory()

Lame, but doesn't seem like there is much else to be done.

cheers,
steve

Indicator Veritatis wrote:
The problem you are having is a good example of why this API,
Environment.getExternalStorageState(), is deprecated. As the online
reference says, "This call should be deprecated as it doesn't support
multiple volumes. "

But this is exactly the problem you encountered: the Galaxy S has TWO
volumes, which they happen to call '/sdcard' and /sdcard/sd' -- a
regrettable choice.

Even more regrettable is that the same reference that says "should be
deprecated", still shows sample code that matches yours very closely.
Nor does it say what to use in place of the "should be deprecated"
API, though it seems to suggest using
Environment.getExternalStoragePublicDirectory() might help.

But see
http://groups.google.com/group/android-developers/browse_thread/thread/96f15e57150ed173/e325904dd01d8a9c?lnk=gst&q=incredible+getExternalStorageDirectory
also.

On Aug 18, 1:52 pm, john brown<[email protected]>  wrote:
Hello,

I have my application running on a Motorola droid. We have
successfully used it in the intended enviornment for 2 days collecting
340 readings. The app is not full featured but it is running. The data
storage is complete and we store, create, delete... small data files
on the sdcard. Our design team prefers, in this application, the small
files on the external storage sdcard and does not want to use sqlLite.

My beta tester purchased a AT&T Samsung Captivate (Samsung SGH-i897).
It seems to have two sdcards. In an earlier thread on this list, they
were referred to as an "internal sdcard" and an "external sdcard". Our
test unit has both installed. I am having trouble accessing the
external storage sdcard. I utilized the code 
fromhttp://developer.android.com/guide/topics/data/data-storage.htmlto
determine if the sdcard is installed and readable and writeable. The
code is:

     public static boolean cksdcard(){
         boolean mExternalStorageAvailable = false;
         boolean mExternalStorageWriteable = false;
         String state = Environment.getExternalStorageState();
         if (Environment.MEDIA_MOUNTED.equals(state)) {
                 // We can read and write the media
                 System.out.println("in cksdcard, MEDIA_MOUNTED");
                 mExternalStorageAvailable = true;
                 mExternalStorageWriteable = true;
         }
         else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
                 // We can only read the media
                 System.out.println("in cksdcard, MEDIA_MOUNTED_READ_ONLY");
                 mExternalStorageAvailable = true;
                 mExternalStorageWriteable = false;
                 }
         else {
                 // Something else is wrong. It may be one of many other states,
but all we need
                 //  to know is we can neither read nor write
                 System.out.println("in cksdcard, Something else is wrong");
                 mExternalStorageAvailable = false;
                 mExternalStorageWriteable = false;
         }
         return mExternalStorageWriteable;
     }

This code returns False which means it is neither readable or
writeable. It prints the else - "in cksdcard, Something else is
wrong".

The app will not run on the Samsung Captivate because it cannot access
the data files on the sdcard.

Strangely, when I mount the device on the desktop computer, windows
explorer shows two (2) connected usb drives which it calls E: and F:.
E: is blank. I can copy the files to F:\Android\data\lms\mpT......
with windows explorer. Windows explored does not show /sdcard
anywhere, it is probably using an Alias?

android.os.Environment.getExternalStorageDirectory() returns "/sdcard"
on BOTH the Moto droid and the Samsung Captivate.

''adb shell" works on the Samsung Captivate. "ls -l /sdcard" returns
"access denied" or something like that. "ls -l" does show /sdcard in
the root directory with the following attributes: "d---------" which
means the owner, group, and user (everybody) have no rights at all.

Any suggestions how I might get read and write access to the sdcard on
the AT&T Samsung Captivate?

Thanks, John Brown



--
stephen lau | [email protected] | http://whacked.net | @stevel

--
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

Reply via email to