I am creating my first android application. The idea is this: there is a page with the user's personal data + his avatar. When you first start, put a picture-stub, but the user can change it, and the Uri image should be saved in the database, so that when it is downloaded later, the application takes it and substitutes the image from the gallery. When you first start and select a picture from the gallery, everything is OK - the picture is substituted. When restarting the application, I get an error.
Uri save code:
final InputStream imageStream = getContext().getContentResolver().openInputStream(mUri); image_source = BitmapFactory.decodeStream(imageStream); //output Log.d("Path:",mUri.toString()); data.put("c_pic",mUri.toString()); db.update("mdb_table_contacts", data, "c_id=" + 1, null); When restarting, I tried different options:
one)
Uri bufUri = Uri.parse(pic_uri); image_source = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), bufUri); 2)
final InputStream imageStream = getContext().getContentResolver().openInputStream(bufUri); image_source = BitmapFactory.decodeStream(imageStream); But I get the error:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.eugen.businesscard, PID: 13648 java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{26db29e9 13648:com.example.eugen.businesscard/u0a87} (pid=13648, uid=10087) requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS at The contents of the file manifest:
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" /> Maybe I should save Uri otherwise, or maybe you can advise another way of implementation? Thank.