android createTempFile throws permission denied?

孤者浪人 提交于 2019-11-29 03:49:34
Marc Bernstein

You need to create the temp files in a directory that your application owns. You should use createTempFile(String prefix, String suffix, File directory), where directory is the location to which the temp file is to be written. You can get a valid location for directory with the result from Context.getFilesDir() or Context.getDir(String name, int mode).

Gonzalo

I think that you just missed the permission to write at the external storage, since temp files are created there by default. Add

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

to your manifest and it should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!