开发者

Unable to create nomedia file

开发者 https://www.devze.com 2023-04-02 22:08 出处:网络
Through Android SDK and AVD Manager I have created an AVD of android3.0 version with size option as 1024MiB. In my application class I have asked to create a directory so that I can cache images. But

Through Android SDK and AVD Manager I have created an AVD of android3.0 version with size option as 1024MiB. In my application class I have asked to create a directory so that I can cache images. But I get error over there as

09-07 15:32:31.253: ERROR/AndroidRuntime(380): Caused by: java.lang.IllegalStateException: Unable to create nomedia file.

My code is:

File baseDirectory = new File(Environment.getExternalStorageDirectory(), "myapp");
File storageD开发者_如何学编程irectory = new File(baseDirectory, "imagecache");
File nomediaFile = new File(storageDirectory, NOMEDIA);
nomediaFile.createNewFile();

Error comes over in the 4th line. Could anyone please help me out. I am new to honeycomb. Thanks in advance.


As others have suggested, you should have mkdirs() to ensure your directory path is there. You also need the WRITE_EXTERNAL_STORAGE permission.

0

精彩评论

暂无评论...
验证码 换一张
取 消