For what it stands, the platform today does not support more than one
external storage directory.  Manufacturers who are adding an SD card in
addition to internal "external" storage are adding features that
applications written against the standard platform are not expected to
support -- they should be able to rely on there being one external storage
directory with one state and not need to care about others.

I realize this doesn't help when users are asking for support for whatever
extra stuff a manufacturer has added...  but please look at it as going
above and beyond the call of duty. :}  And since this is not a part of the
standard platform, unfortunately you'll find the way this stuff works to
vary across manufacturers.

It's possible there will be a standard API for this in the future...  but to
be honest, it is hard for me to imagine dealing with multiple external
storage locations as resulting in a decent user experience, so it may not
happen.  Just causing the user have to be aware that they have some pictures
in their internal storage and some in the external SD card, and how much
space they have on each, and what to do if one is full...  yuck.

On Thu, Aug 19, 2010 at 7:03 PM, john brown <johnbrowngreybe...@gmail.com>wrote:

> I do appreciate the comments and suggestions. They give me new things
> to try.
>
> The good news it the app is working on the Samsung SGH-i897 now. The
> bad news is I do not know why. Here is what happened:
>
> 1) I hard coded "/sdcard/sd" rather than getting the path
> programatically. (I did not have much time.)
> 2) I got the same error, something like "path not found"
> 3) I went back into the code and removed the hard coded path.
> 4) I added a System.out.println("ext storage is " + myPathVariable)
> 5) I ran it one more time just to check what the output path was
> again.
> 6) It ran, no errors.
> 7) The output was "ext storage is /sdcard/Android/data/lms/mp...."
>
> That is the same path it printed when it got the error. A satisfactory
> explanation would be that my memory is wrong or I did not type what I
> thought I typed, but I cannot find the error.
>
> I do not know why. But it is working. :>)
>
> I will test some more tomorrow.
> I will stop using - Environment.getExternalStorageState()
> I will try - Environment.getExternalStoragePublicDirectory()
>
> Right now I am thinking it has more to do with the phase of the moon
> than with concrete facts. Like it does not work Friday through
> Wednesday. But it does work on Thursday!
>
> Again thanks for all the help. John Brown
>
> On Aug 19, 3:19 pm, Stephen Lau <st...@grommit.com> wrote:
> > 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/threa.
> ..
> > > also.
> >
> > > On Aug 18, 1:52 pm, john brown<johnbrowngreybe...@gmail.com>  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 | st...@grommit.com |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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to