Android Question SharedFolder is blank when I try to use FileProvider

dieterp

Active Member
Licensed User
Longtime User
I am trying to use FileProvider to share a file from my app via WhatsApp. When I try run the code to do this I get the following error:

B4X:
java.io.FileNotFoundException: scorerdb.db: open failed: EROFS (Read-only file system)

When I log the SharedFolder property I see that it is empty. I have another almost identical app that does manage to successfully use FileProvider to share a file via WhatsApp. However when I copy the code across I get the above error. Any suggestions where I'm going wrong?
 

asales

Expert
Licensed User
Longtime User
Post the code that you try to run.

Check the original example:
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
B4X:
Dim FileName As String = "scorerdb.db"
    Log(Provider.SharedFolder)
    
    If File.Exists(Main.rp.GetSafeDirDefaultExternal(""), "scorerdb.db") = True Then
        File.Copy(Main.rp.GetSafeDirDefaultExternal(""), "scorerdb.db", Provider.SharedFolder, "scorerdb.db")
    End If
    
    Dim email As Email
    email.To.Add("support@websports.co.za")
    email.Subject = "WebScorer DB"
    email.Attachments.Add(Provider.GetFileUri(FileName))
    
    Dim in As Intent = email.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)

I have also added tried adding the below code to the Manifest but not getting any luck there either. What I can say is that the below code is not part of the Manifest if the other app where FIleProvider is working

B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)
 
Upvote 0
Top