You will need to compare its code to your code.
This is a mistake. You should use FileProvider library.
Why do you need the external storage permission?
Post the full error message from the logs.
Thank you Erel. The external storage permission was leftover from another sub which lets users copy the files elsewhere. I took it out
I loaded the FileProvider library and removed the class, but I'm still getting the same error.
Code:
Dim filename As String
File.MakeDir (File.DirInternal,"shared")
provider.Initialize
provider.UseFileProvider=True
provider.SharedFolder =File.DirInternal & "/" & "shared"
checkedJobs.Initialize
Dim i As Int=0
For i = 0 To clvFiles.GetSize - 1
Dim p As B4XView = clvFiles.GetPanel(i)
Dim pl As B4XView =p.GetView(1)
Dim chk As B4XView = p.GetView(0)
If chk.Checked Then
filename=pl.tag
File.Copy(JobDir,pl.Tag, provider.SharedFolder,filename)
checkedJobs.Add(filename)
End If
Next
Dim msg As Email
msg.Subject ="Job files -" & DateTime.Date(DateTime.Now)
msg.Body ="Database files from user: " & usuario & CRLF & "Date: " & DateTime.Date(DateTime.Now)
For i=0 To checkedJobs.Size-1
filename = checkedJobs.Get(i)
msg.Attachments.Add(provider.GetFileUri(filename))
Next
Dim intMsg As Intent = msg.GetIntent
intMsg.Flags=1
StartActivity(intMsg)
This is the error log:
Using FileProvider? true
Error occurred on line: 34 (FileProvider)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at SICAD.SAFO.fileprovider._getfileuri(fileprovider.java:122)
at SICAD.SAFO.main._cmdmail_click(main.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6935)
at android.widget.TextView.performClick(TextView.java:12752)
at android.view.View$PerformClick.run(View.java:26214)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority SICAD.SAFO.provider
at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:606)
at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:579)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:417)
... 23 more