The Situation:
I decremented a Uri
First, I converted the Uri into a string and in turn into an int
Afterwhich, I did a -1, and then I got the string that looks exactly like a decremented string
However, when I parse the uri and try to setImageURI() on it,
it is showing "File error accessing recents directory (directory
doesn't exist?)."
Here is the code that I have used:
Uri ImageUri = data.getData();
String uri1 = ImageUri.toString();
//region uri2
String substr1 = uri1.substring(uri1.length()-3);
int substr1int = parseInt(substr1)-1;
String decrementedstr1 = new Integer(substr1int).toString();
int numberofchars1 = uri1.length()-3;
String firstcomponent1 = uri1.substring(0, numberofchars1);
String uri2 = firstcomponent1 + decrementedstr1;
//endregion
Uri test = Uri.parse(uri2);
animateobject.setImageURI(test);
Got this Error:
File error accessing recents directory (directory doesn't exist?).
After I used 'Debug App', it showed the error in more details:
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaDocumentsProvider uri content://com.android.providers.media.documents/document/image%3A1000002538 from pid=1309, uid=10925 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
Note: This is in java and I'm using Android Studio to code.