Reputation: 439
I am sure that I have added permission WRITE_EXTERNAL_STORAGE in manifest.xml, and I have also checked the state of SD card using Environment.getExternalStorageState(), makeing sure the value is Environment.MEDIA_MOUNTED, not Environment.MEDIA_SHARED or anything else. Even with these checks passed, there still is a permission denied error when I try to create new files!
This error only occurs on Nexus One so far. For I myself do not have a Nexus One, I cannot debug it directly. Could anybody help me?
Upvotes: 2
Views: 1530
Reputation: 31
As far as I was concerned, Environment.MEDIA_MOUNTED returned false and an IOException (Permission denied) was raised because I forgot to add a SD card to my Android Virtual Device.
Upvotes: 3
Reputation: 2739
I think you should try this. Not sure if it will solve your problem:
Environment.getExternalStorageDirectory()
example:
String path= Environment.getExternalStorageDirectory()+"/yourfilename/";
File file = new File(path);
if(!file.exists())
file.mkdirs();
Upvotes: 3