Sunday, June 12, 2011

[android-developers] Can't write to sdcard

I am attempting to save data to the sdcard with the following code but
get a file not found exception:

String fileContents = fileBuf.toString();
Log.d(tag, fileContents);
File sdDir = new File("/sdcard/Logger");
sdDir.mkdirs();
File file = new File("/sdcard/Logger/"+currentTripName+".kml");
FileWriter sdWriter = new FileWriter(file, false);
sdWriter.write(fileContents);
sdWriter.close();

When i try the following code (API level 8), I get a similar error.

File sdDir = getExternalFilesDir(null);
File file = new File(getExternalFilesDir(null) + currentTripName
+".kml");
FileWriter sdWriter = new FileWriter(file, false);
sdWriter.write(fileContents);
sdWriter.close();

Any suggestions? This is driving me nuts.


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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate