Android Question How do I copy a file to an External SDCard

davepamn

Active Member
Licensed User
Longtime User
B4X:
    Dim sSourceFile As String=SQLLite.oDB.sPrivateDatabaseName
    Dim sDestinationFile As String=SQLLite.oDB.sPrivateDatabaseName
    Dim sDirSource As String=File.DirRootExternal
    Dim sDirTarget As String=File.DirDefaultExternal

    Try

    File.Copy(sDirSource, sSourceFile, sDirTarget, sDestinationFile)
    ToastMessageShow(sDirTarget & sDestinationFile,True)
    Catch
        oError.ShowLastException("Error : BackupDB_Click")
    EndTry

The code is copying my file to the internal SDCard.

I inserted the following directive in my manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 

davepamn

Active Member
Licensed User
Longtime User
What does the CanInstallToExternalStorage directive do?

I read the article. Can you provide me the code snippet that I should use to access the sdcard directory? It seemed like a application specific directory had to be created like com.b4a.myapp. Is this true? Or does the api create the directory?
 
Upvote 0
Top