Android Question Problem accessing file system

Lakhtin_V

Active Member
Licensed User
Longtime User
Hello, I often use the code to connect to the file with the application settings. This code always worked successfully. But now in the new application an error occurs. I think that the problem is with some restrictions. But I did everything as usual.

Copy file:
    If File.Exists(File.DirInternal,"LoRa.db")=False Then
        Log("~~~~~~~~~~~~~ COPY SQL DB ~~~~~~~~~~~~~~")
        File.Copy(File.DirAssets,"LoRa.db", File.DirInternal,"LoRa.db")
    End If
    SQLdb.Initialize(File.DirInternal,"LoRa.db",False)

In manifest file

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "LoRa+GPS")
CreateResourceFromFile(Macro, Themes.LightTheme)
AddPermission("android.permission.ACCESS_FINE_LOCATION")
AddPermission("android.permission.ACCESS_NOTIFICATION_POLICY")
AddPermission("android.permission.MOUNT_UNMOUNT_FILESYSTEMS")

1728994836246.png


Errors

erros:
Logger connected to:  Xiaomi 23028RNCAG
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **

main$ResumableSub_Activity_Createresume (java line: 465)
java.io.FileNotFoundException: lora.db
    at android.content.res.AssetManager.nativeOpenAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:908)
    at android.content.res.AssetManager.open(AssetManager.java:885)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:208)
    at anywheresoftware.b4a.objects.streams.File.Copy(File.java:341)
    at lora.b4a.main$ResumableSub_Activity_Create.resume(main.java:465)
    at lora.b4a.main._activity_create(main.java:438)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at lora.b4a.main.afterFirstLayout(main.java:105)
    at lora.b4a.main.access$000(main.java:17)
    at lora.b4a.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7941)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)
 

DonManfred

Expert
Licensed User
Longtime User
java.io.FileNotFoundException: lora.db
make sure to use lowercased filesname. maybe that´s the issue?

Rename LoRa.db in your Files folder to lora.db
Change all occurences of LoRa.db in your code to lora.db
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
make sure to use lowercased filesname. maybe that´s the issue?

Rename LoRa.db in your Files folder to lora.db
Change all occurences of LoRa.db in your code to lora.db
But still there is a bug. If you try to rename a file from the B4A window it does not work correctly. But when you rename a file in Windows Explorer it is a more reliable way.
 
Upvote 0
Top