Android Question Error copying the database SQLITE to android

Alaoui Mohamed Moctar

New Member
Licensed User
Hi

Can not execute this command
File.Copy (File.DirAssets, "alaoui.db", File.DirDefaultExternal, "toto.db")
message type
Logger connecté à : S88TLVC6IBZ5ZLMB
--------- beginning of crash
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **

main_activity_create (java line: 363)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/toto.db: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:487)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
at anywheresoftware.b4a.objects.streams.File.Copy(File.java:341)
at b4a.example.main._activity_create(main.java:363)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Alaoui Mohamed Moctar

New Member
Licensed User
You should never use File.DirDefaultExternal:
Runtime Permissions (Android 6.0+ Permissions)
Thank you for responding quickly,

I am a new user of your product and I am familiar with,
I was following trainings using the same command. I only need to copy my SQLITE database to my adroid what do I have to do as a command

If File.Exists(File.DirAssets, "alaoui.db") Then
File.Copy(File.DirAssets, "alaoui.db", File.DirDefaultExternal, "toto.db")
Log("OK !, Base chargée BBBB...")
sql1.Initialize(File.DirDefaultExternal, "toto.db", False)
Log("OK !, Base chargée ...")
Else
Log("No !, Base non chargée ...")
End If
 
Last edited:
Upvote 0
Top