Under Android 6 without removable SD-card - ExternalWritable = True, but SQLite db file cannot be copied by
and TargetDir = File.DirDefaultExternal
In the line with File.Copy - there is the error:
And mostly on Samsungs.
How to be sure ?
B4X:
Sub CopyDBFromAssets (FileName As String) As String
Dim TargetDir As String
If File.ExternalWritable Then
TargetDir = File.DirDefaultExternal
Else
TargetDir = File.DirInternal
End If
If File.Exists(TargetDir, FileName) = False Then
File.Copy(File.DirAssets, FileName, TargetDir, FileName)
End If
Return TargetDir
End Sub
and TargetDir = File.DirDefaultExternal
In the line with File.Copy - there is the error:
B4X:
Error occurred on line: 531 (inetsrv)
java.io.FileNotFoundException: /storage/emulated/0/Android/data/peacemaker.energeniepowermanager/files/db.sqlite: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:370)
at anywheresoftware.b4a.objects.streams.File.Copy(File.java:336)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:748)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
And mostly on Samsungs.
How to be sure ?