i am trying retrieve image but it's not working if i restart my application
i am getting this error
E/path: getRealPathFromURI Exception : java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord{c3b0cec 9068:com.rayvatapps.launcher/u0a94} (pid=9068, uid=10094) that is not exported from UID 10066
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: / (Permission denied)
please help me any suggestion would be helpful
What I have tried:
<pre>SharedPreferences sharedPreferences = getSharedPreferences("MyFile", 0);
String image = sharedPreferences.getString("image","");
if(!image.equals(""))
{
Uri path = Uri.parse(image);
if(!path.equals(""))
{
File f = new File(getRealPathFromURI(mContext,path));
Drawable d = Drawable.createFromPath(f.getAbsolutePath());
rlMain.setBackground(d);
}
}
method
private String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = {
MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(
MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {
Log.e("Path", "getRealPathFromURI Exception : " + e.toString());
return "";
} finally {
if (cursor != null) {
cursor.close();
}
}
}