Android Question File Association - Reading the file

andyp

Member
Licensed User
Hi. When I click on an emailed file (*.f3a) my app automatically opens - I have the file association working fine . I can also open the app by clicking on a .f3a file saved to my device. So I think I have the manifest file working ok.

My problem is reading the contents of the file.

The .f3a file is just a text file with 7 lines I wish to read into an array - I think using File.ReadList

My code errors at the File.ReadString - java.io.FileNotFoundException: No content provider: 0@media/external/file/38

And if I remove this line (its only a log), I get an error at File.ReadList.

How do I correctly find the directory and filename of a file used to open the app by association?

B4X:
Sub Activity_Resume

    Dim intent1 As Intent
    intent1 = Activity.GetStartingIntent
    If intent1 <> Null Then  
        Dim UriString As String = intent1.GetData      
        Dim Dir, FileName As String       
    If UriString.StartsWith("file://") Then
        FileName = UriString.Substring("file://".Length)
        Dir = ""
    Else If UriString.StartsWith("content://") Then
        FileName = UriString.Substring("content://".Length)
        Dir = "ContentDir"        
        End If
        
        Log(File.ReadString(Dir, FileName))
   
        Dim List1 As List
        List1 = File.ReadList(Dir, FileName)
       Msgbox("List1.Size = " & List1.Size & CRLF & "The third item is: " & List1.Get(2), "")
    
      End If
  
End Sub

Any help greatly appreciated! Thank you, Andrew
 

andyp

Member
Licensed User
Hi

(Intent) Intent { act=android.intent.action.VIEW dat=content://0@media/external/file/38 typ= flg=0x1 cmp=b4a.example/.emailedbox (has extras) }

and

Bundle[{AbsolutePath=/storage/emulated/0/Download/EmailedBox.f3a, from-myfiles=true, key_filename=/storage/emulated/0/Download/EmailedBox.f3a, android.intent.extra.STREAM=content://0@media/external/file/38}]

Thank you for your help!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…