Android Createtempfile Throws Permission Denied?
Solution 1:
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)
.
Solution 2:
I think that you just missed the permission to write at the external storage, since temp files are created there by default. Add
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />
to your manifest and it should work.
Solution 3:
Even after adding <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" this to manifest I was getting error. But after adding this android:requestLegacyExternalStorage="true" in application tag of manifest file I am able to createTempFile and able capture pic from phone.
<application android:requestLegacyExternalStorage="true"
Post a Comment for "Android Createtempfile Throws Permission Denied?"