Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
SonidoFondo.Initialize
BaseDeDatos.Initialize(File.DirDefaultExternal,"basededatos.db",True)
End If
Log("Número de líneas = " & BaseDeDatos.ExecQuerySingleResult("SELECT count(*) FROM Prueba"))
'Preparación del sonido de Fondo
PreparaSonidoDeFondo
SonidoFondo.Play
'Carga de la pantalla principal
Activity.LoadLayout("principal")
End Sub
but return to me error 14.... can't open database.....
My file is on Files folder and I include on Files B4A to copy on my device......
The DB will be included with the App. But, initially on the device, as with all the other items in the Files folder it will be in a read only area. It needs to be moved to a Read Write area, from DirAssets (read only) to DirInternal (read/write, but still only internal to your App, if not already there) and then opened.
Something like :
B4X:
If FirstTime = True Then
If File.Exists(File.DirInternal,"themsc.db") = False Then
File.Copy(File.DirAssets,"thedatabase.db",File.DirInternal,"thedatabase.db")
End if
End if
eta :
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirInternal,"thedatabase.db", True)
End If