When saving the a file to internal storage, some people get this massage:
java.io.FileNotFoundException: /data/data.../MyFile (Permission denied)
What might be the problem? I create my file like this:
FileOutputStream fos = context.openFileOutput("MyFile", Context.MODE_PRIVATE); // Line t开发者_Python百科o cause the exception
and context is my activity the is sent as a parameter to the save function (static function). Should I use some Activity.getBaseContext or something like that? Any ideas what might be the problem?
Are you missing permissions in your manifest...? You should have the following at the application level...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I've run into the exact same issue. In my case, my guess is that there was something locking the files because I couldn't delete some of them either.
I had to use adb shell and delete the whole directory (using rm -r) to get this working.
Are you using a simulator or a device? Which one? If you're using a simulator, maybe your cache partition is out of space. You can set "Cache partition size" parameter using AVD Manager.
For the record, I'm using the Galaxy Tab emulator from Samsung.
精彩评论