Android Question Write access on external SD-Card

Discussion in 'Android Questions' started by GuenterL, Feb 9, 2019.

  1. GuenterL

    GuenterL Member Licensed User

    Hi guys

    I do have a problem with writing on an SD-Card.
    In the small test program, I defined a storage directory called "GPSDir" to store a huge amount of GPS data.

    Sub Process_Globals
    Dim RP As RuntimePermissions
    Dim Writer As TextWriter
    End Sub

    Sub Globals
    Dim sp_storage As Spinner
    Dim GPSDir = RP.GetSafeDirDefaultExternal("GPSDir"As String

    End Sub
    In the activity I filled a spinner with the two valid values:

    Sub Activity_Create(FirstTime As Boolean)
    "Select Path")
    For Each s As String In RP.GetAllSafeDirsExternal("GPSDir")
    End Sub
    Possible values are:

    The idea is to select , which dir will be used to store a simple file.

    Sub sp_Storage_ItemClick (Position As Int, Value As Object)
            GPSDir = Value
    End Sub

    Sub write_data
    If File.Exists(GPSDir, "Test.txt") = False Then
    File.OpenOutput(GPSDir, "Test.txt"True))
    End If
    End Sub

    Running the pogram, IT WORKED FINE to store a file into the internal memory,
    but failed by using the sd-card.

    Error message : /storage/sdcard1/Android/data/b4a.example3/files/GPSDir/Test.txt: open failed: EINVAL (Invalid argument)

    I am running B4A 8.5 on Anroid7 Client.

    Are there different permissions on memory and sdCard ?
    Which is the correct way to select, which path will be used ?

    Many thanks guenterl
  2. DonManfred

    DonManfred Expert Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice