filepath1 = Main.SQL.execQuerySingleResult("SELECT path FROM Attachments where attachno = " & QUOTE & Main.attachno & QUOTE)
filename1 = Main.SQL.execQuerySingleResult("SELECT filename FROM Attachments where attachno = " & QUOTE & Main.attachno & QUOTE)
filepath1 = filepath1 & "/" & filename1
' Dummy is just a convenient file to have put in DIRASSETS.
' Copy file from Database to DIRASSETS
File.Copy(File.DirAssets, "Dummy.docx", Starter.shared, filename1)
Dim in As Intent
' Get URL of the file now in DIRASSETS
in.Initialize(in.ACTION_VIEW, CreateFileProviderUri(Starter.shared, "Dummy.docx"))
in.Flags = 1
Sub CreateFileProviderUri (dir As String, filename2 As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(dir, filename2))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub