Mahendra/String,
Thank You for your reply on this. The problem was with the following code as
pointed correctly by you folks
String state = Environment.getExternalStorageState();
if(state != Environment.MEDIA_MOUNTED) {
Log.d("DEBUG", "The Card is Not Mounted " + state +"--");
throw new IOException ("SD Card is not Mounted. It is in " +
state);
After hardcoding the path as per the code below (pointed by Mahendra) I'm
able to write the file onto the SD Card and see the same in DDMS
/sdcard/somefilename
I think this problem is only with Emulator as mentioned in Emulator
Limitations in Android Docs->Tools->Emulator.
Further Questions
1. Would the code like Environment.getExternalStorageState.....etc work when
using the actual device.
2. Would the path name like /sdcard be the same when connected to the actual
device.
Thanks & Best Regards
Acer
On Wed, Feb 3, 2010 at 11:58 AM, Mahendra
<[email protected]>wrote:
> Hi,
>
> Following code is writting data to the Sdcard.
>
> try {
>
>
> FileWriter fOut = new FileWriter("/sdcard/samplefile1.txt");
>
> final String TESTSTRING = new String("Hello Android
> Development team");
>
> BufferedWriter osw = new BufferedWriter(fOut);
>
> // Write the string to the file
>
> osw.write(TESTSTRING);
>
> /* ensure that everything is
> * really written out and close */
>
> osw.flush();
> osw.close();
>
> } catch (IOException ioe) {
> ioe.printStackTrace();
> Toast.makeText(this, "WriteFailed!",
> Toast.LENGTH_SHORT).show();
> }
>
>
>
> <uses-permission
> android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
>
>
>
>
> Regards,
>
> Mahendra G
>
> On Feb 3, 10:09 am, Ace <[email protected]> wrote:
> > Hello Mark,
> > Yes, I do get the SD card image, attached is the screen-shot for your
> > reference.
> >
> > Thank You again for your help
> >
> > Regards
> > Acer
> >
> > On Wed, Feb 3, 2010 at 12:56 AM, Mark Murphy
> > <[email protected]>wrote:>
> > Regarding your question ....."Are you sure your emulator has an SD card
> > > > image? They don't by default"
> >
> > > > Yes I think it has SD card image as I'm able to see the same through
> DDMS
> > > > File Explorer when I startup the emulator.
> > > > However, when I try and access it through Downloader.java I get Card
> Not
> > > > Mounted.
> >
> > > A better test is to bring up the AVD Manager (run tools/android from
> your
> > > SDK, or Windows|Android and AVD Manager from Eclipse). From there,
> > > highlight your AVD and click the [Details...] button. If the emulator
> has
> > > an SD card image, it will appear just above the horizontal line.
> >
> > > --
> > > Mark Murphy (a Commons Guy)
> > >http://commonsware.com
> > > Android App Developer Books:http://commonsware.com/books.html
> >
> > > --
> > > 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]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> >
> >
> > my-emulator-details.bmp
> > 1462KViewDownload
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
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