如何处理以下异常
java.lang.SecurityException: Permission Denial: writing com.android.providers.media.......requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()
我已经在androidManifest中添加了以下权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
代码如下
我有一个Uri数组
AddArry[]
try{
getContentResolver().releasePersistableUriPermission(AddArray[i],Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
grantUriPermission(getApplicationContext().getPackageCodePath(),AddArray[i],Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
parcelFileDescriptor = getContentResolver().openFileDescriptor((Uri)AddArray[i],"w");
fileDescriptor = parcelFileDescriptor.getFileDescriptor();
}
catch(Exception e){
Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_SHORT).show();
}
ExifInterface ei = new ExifInterface(fileDescriptor);
ei.setAttribute(TAG_GPS_LATITUDE, "33/1,35/1,4091/100");
ei.setAttribute(TAG_GPS_LATITUDE_REF, "N");
ei.setAttribute(TAG_GPS_LONGITUDE, "73/1,1/1,4390/100");
ei.setAttribute(TAG_GPS_LONGITUDE_REF, "E");
try {
ei.saveAttributes();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show();
}