Android Question Error copying to file.DirDefaultExternal

Polaris

Member
Licensed User
Hi ,
can anyone please help me with this problem ? I have the standard code for copying a PDF file from DirAssets fo file.DirDefaultExternal to allow a PDF reader to open it as follows :


B4X:
Dim I1 As Intent
    Dim PDF_Filename As String = "fattura.pdf"
  
    
78           If File.Exists(File.DirAssets,PDF_Filename) = True Then
79           File.Copy(File.DirAssets,PDF_Filename,File.DirDefaultExternal,PDF_Filename)
    
 80       End If


Android 7.1 device Samsung Galaxy A7 phone…... app crashes
Android 7.0 device Huawei P9 phone .........app does nor crash but i get this message " No apps can perform this action"


The error log reads as follows :
-----------------------------------------------------------------------------------------------------------------

Error occurred on line: 79 (BillList)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/fattura.pdf (No such file or directory)

-------------------------------------------------------------------------------------------------------------------

fattura.pdf exists in DirAssets as i have a sub that checks this and it returns positive.


Is this a runtime permission problem ?
In the Logs tab ---> List Permissions I have :
-----------------------------------------------------------------------------------------------------------------

FileDirRootExternal/File DirDefaultExternal
android.permission.WRITE_EXTERNAL_STORAGE*
------------------------------------------------------------------------------------------------------------------


Any help is greatly appreciated.
 

Polaris

Member
Licensed User
Hi Erel,

Thanks for the reply , yes i did watch the video , but since in the tutorial you said:

>>>>READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE

This is the most common dangerous permission. It is added automatically when you use File.DirDefaultExternal or File.DirRootExternal. <<<<<




I just interpreted that as meaning it was all done automatically when File.DirDefaultExternal is used.

Anyway I followed your advice ad used rp.GetSafeDirDefaultExternal("") as explained in the tutorial, and it works like a charm.

Thank you again
 
Upvote 0

Similar Threads

Top