Android Question Unable to store in Pictures folder

jlalexie

Member
Licensed User
I'm trying to store an image in pictures.
But I get an error message:

java.lang.RuntimeException:

java.io.FileNotFoundException: /storage/emulated/0/Pictures/Image5_1.jpeg: open failed: EPERM (Operation not permitted)


I suppose there is a problem with permissions, but I don't know this subject.
Attached my manifest file.

Dim picturesFolder As String = File.Combine(File.DirRootExternal, "Pictures" )
StoreCanvasToJpeg (picturesFolder,filename)
Sub StoreCanvasToJpeg (folder As String, filename As String)
Dim Out As OutputStream

............


Out = File.OpenOutput(folder, filename, False)
CanvasCible.Bitmap.WriteToStream(Out, 100, "JPEG")
Out.Close
End Sub
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
 

Attachments

  • manifest.JPG
    manifest.JPG
    97.4 KB · Views: 92

Alexander Stolte

Expert
Licensed User
Longtime User
Please read the following thread:
especially the area of "READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE"
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Any chance the format of the problem image is not the same format as the rest of the images in the folder?
 
Last edited:
Upvote 0

jlalexie

Member
Licensed User
Thanks for answer

it works (tested on android 8 to 11)

I already have in manifest:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
I made the following changes
In manifest
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
Add runtime permission in main
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = True Then
Activity.LoadLayout("main")
Log(rp.GetSafeDirDefaultExternal(""))
Else .....
End If

I store images in the folder
picturesFolderRoot As String = "/storage/emulated/0/DCIM/CEMP"

For others app datas to store:
StoreFolder=rp.GetSafeDirDefaultExternal("")
 
Upvote 0
Top