Hi, I'm using the ContentChooser to locate a PDF on the android, and pass it to a copy file.
Apparently it works correctly, I would like to know if it is correct like this, or is there any recommended method?
Apparently it works correctly, I would like to know if it is correct like this, or is there any recommended method?
B4X:
dim cc As ContentChooser
cc.Initialize("cc")
cc.Show("application/pdf", "Choose pdf")
....
Sub cc_Result (Success As Boolean, Dir As String, filename As String)
If Success=True Then
If File.Exists(Starter.Provider.SharedFolder,"file.pdf") Then File.Delete (Starter.Provider.SharedFolder,"file.pdf")
Dim jo As JavaObject
Dim cd As String = jo.InitializeStatic("anywheresoftware.b4a.objects.streams.File").GetField("ContentDir")
Dim in As InputStream = File.OpenInput(cd, filename)
Dim out As OutputStream = File.OpenOutput(Starter.Provider.SharedFolder,"file.pdf", False)
File.Copy2(in,out)
out.Close
If File.Exists(Starter.Provider.SharedFolder,"file.pdf") Then
....
End If
End If
end sub