Wednesday, June 15, 2011

[android-developers] Re: Can't write to sdcard

File file = new File(sdDir + "/" + currentTripName + ".kml");
yields:
06-15 13:25:29.209: WARN/System.err(13412):
java.io.FileNotFoundException: /mnt/sdcard/2011Jun1419:37.kml (Invalid
argument).

I also checked the file permissions, which are: lwrxwrxwrx root root.
After that i remounted the sdcard in adb, but results are still the
same.

Any other thoughts?


On Jun 13, 8:53 am, Mike <j.m.roya...@gmail.com> wrote:
> check the file name and be sure it's ok.
>
> Running a modified version of your code on a 2.3.3 emulator
>
>                 File sdDir = Environment.getExternalStorageDirectory();
>                 sdDir.mkdirs();
>                 String currentTripName = "testtrip";
>                 File file = new File(sdDir + currentTripName + ".kml");
>                 FileWriter sdWriter;
>                 try {
>                         sdWriter = new FileWriter(file, false);
>                         String fileContents = "This is a test trip file";
>                         sdWriter.write(fileContents);
>                         sdWriter.close();
>
>                 } catch (IOException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>
> yeilds this error
>
> 06-13 12:45:03.358: WARN/System.err(1663):
> java.io.FileNotFoundException: /mnt/sdcardtesttrip.kml (Read-only file
> system)
>
> maybe try
>
> File file = new File(sdDir + "/" + currentTripName + ".kml");

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

No comments:

Post a Comment