> I've been developing this one app for a few months now with eclipse.
> I've had no problem writing to the sdcard in the past. Now it just
> creates an empty file when the following code is used:
>
>
>
> try {
> FileWriter fw = new FileWriter("/sdcard/shootme.txt");
>
> BufferedWriter out = new BufferedWriter(fw);
> out.write("help! I'm going crazy");
> out.close();
>
> } catch (IOException e) {
> Toast.makeText(cntx, "WriteFailed!", Toast.LENGTH_SHORT).show();
> }
> Toast.makeText(cntx, "Written! " , Toast.LENGTH_SHORT).show();
>
>
>
> It runs fine and the last toast pops up like everything is fine... but
> no... it's an empty file that got created!
>
> I was just making code changes on what was written and all of a sudden
> this happens. I did notice that when using WinImage to manage the
> sdcard, the attributes were changed to Archive.
>
> I deleted the avd and sdcard I was using and created a new one just in
> case and it still happens.
>
> I checked and all my other apps do the same thing... a different
> computer did the same thing. An app with just the code above doesn't
> work either. I tried SuperCSV.jar and it just writes an empty file.

1. Please use Environment.getExternalStorageDirectory(), rather than
assuming that /sdcard is the correct path. It is not the correct path on
some Android devices.

2. Do you have the WRITE_EXTERNAL_STORAGE permission?

-- 
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to