Android Question Write to File

FlyingEagle

Member
Licensed User
Longtime User
I tried a lot but nothing works for me ... Google Pixel 3 XL Android 11 No-Root-Access

I want to write to files, I tried every single option from File.Dir_xxxx

I want to write to my own Directory on /data/emulated/0/xxxx.

I tried here
Sub Activity_PermissionResult:
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
  
    If Permission = Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION Then
        Result = True
    Else
        Log ( "PERMISSION_ACCESS_COARSE_LOCATION" )
    End If
  
    If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
        Result = True
    Else
        Log ( "PERMISSION_ACCESS_FINE_LOCATION" )
    End If
  
    If Permission = Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE Then
        Result = True
    Else
        Log ( "PERMISSION_READ_EXTERNAL_STORAGE" )
    End If
  
    If Permission = Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE Then
        Result = True
    Else
        Log ( "PERMISSION_WRITE_EXTERNAL_STORAGE" )
    End If
  
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
  
End Sub


Or here

Sub Activity_Create:
Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
  
'    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION)
'    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
'    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
'    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)

    For Each permission As String In Array( Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION, _
                                            Starter.rp.PERMISSION_ACCESS_FINE_LOCATION, _
                                            Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE, _
                                            Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE )
                                          
        Starter.rp.CheckAndRequest(permission)
      
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
      
        If Result = False Then
            Log ("No permission!" ) ', True)
            Activity.Finish
            Return
        End If
    Next

End Sub


Or here

Manifest:
AddManifestText            (
                            <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>
                            <supports-screens    android:largeScreens="true"
                                                android:normalScreens="true"
                                                android:smallScreens="true"
                                                android:anyDensity="true"/>
                            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
                            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                            <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
                            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
                        )

It took me the whole evening ... who can help?


PS: Where do this lines have to be, in front of or at last of the code of a sub?

Delegate:
B4XPages.Delegate
 

mevial

Member
Licensed User
Longtime User

Did not compiles with this string:
B4A Версия: 10.2
Java Версия: 8
Анализ кода.    (0.17s)
Building folders structure.    (0.02s)
Компиляция кода.    (0.20s)
Компиляция кода макетов.    (0.00s)
Организация библиотек.    (0.00s)
    (AndroidX SDK)
Генерирование файла R.    (0.00s)
Компиляция сгенерированного кода Java.    (0.02s)
Преобразование байтового кода - оптимизированный dex.    (4.27s)
Упаковочные файлы.    Error
AndroidManifest.xml:26: error: Error parsing XML: not well-formed (invalid token)

AAPT path: D:\dev\AndriodSDK\tools\..\build-tools\27.0.1\aapt.exe
Exit code:1
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…