Hi All,

This is my code that successfully creates both the directory tree and
the file "myFile.txt", and yet throws a FileNotFoundException when I
try to call new FileOutputStream(file):

File file = new File("/sdcard/zackcorp/myfiles", "myFile.txt");
file.mkdirs();  // creates /sdcard/zackcorp/myfiles
file.createNewFile();
boolean canWrite = file.canWrite();  // canWrite is true
FileOutputStream fos = new FileOutputStream(file);

My theory is that it's not possible to create a FileOutputStream with
an sdcard file (or perhaps anywhere else besides within my package),
because when I change the directory to point to my package's sandbox,
the FileOutputStream is successfully made.

File file = new File("/data/data/com.zackcorp.android/myfiles",
"myFile.txt");
file.mkdirs();  // creates /data/data/com.zackcorp.android/myfiles
file.createNewFile();
boolean canWrite = file.canWrite();  // canWrite is true
FileOutputStream fos = new FileOutputStream(file); // THIS time it
works

Could anyone tell me what I have to do to open a FileOutputStream on a
file on an sdcard?  Or which AndroidManifest permission I could set to
fix this?  Thanks very much!

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