if i deleted how is it work ? where will save data?
i delete db but i still get error what happen ?You had to delete the db first (The blank one with no Tables Defined ) .. then run the new code .. or you will continually get an error.
Try This ..
i delete db but i still get error what happen ?
java.io.FileNotFoundException: /mnt/sdcard/Android/data/b4a.example/files/savedata.db: open failed: EACCES (Permission denied)
Sorry .. Just noticed the New error
Change all File.Dir references to .. File.DirInternal (where you app is)
The is a permission issue try to save to external sd card.
If I understand you correct .. If you have changed the code as suggested above ..but is every think fine with code only that permission problem?
If I understand you correct .. If you have changed the code as suggested above ..
Yes ... All is Good . you only have to save the db elsewhere (File.DirInternal) or search forum to solve saving to External SD.
why is writing?????
no such table: setting: , while compiling: INSERT INTO setting VALUES (Null,?,?)
sql1.Initialize(File.DirInternal,"savedata.db",True)
If File.Exists(File.DirInternal,"savedata.db")=False Then
File.Copy(File.DirAssets,"savedata.db",File.DirDefaultExternal,"savedata.db") '@@ wrong DIR
End If
If File.Exists(File.DirInternal,"savedata.db")=False Then
File.Copy(File.DirAssets,"savedata.db",File.DirInternal,"savedata.db")
End If
sql1.Initialize(File.DirInternal,"savedata.db",False) '@@ change to False .. the db should always exist now.
?? .. Could you try the attached . There should be no reason for it to fail.
the problem was sql1.Initialize(File.DirInternal,"savedata.db",False)
It was only the position of this line that caused a problem.![]()
I don't think you need to root your phone. It may depend on which Android version that support external storage. My phone is not rooted and I usually develop my app to move the db file from asset to Internal and not external to reduce any problem with the storage permission.yes but i think if my phone have root will be working![]()
Sub Process_Globals
Dim DB As SQL
Dim DBFileDir As String
Dim DBFileName As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
DBFileDir = File.DirInternal
DBFileName = "mytenant.db"
If File.Exists(DBFileDir, DBFileName) = False Then
DBFileDir = DBUtils.CopyDBFromAssets(DBFileName)
End If
DB.Initialize(DBFileDir, DBFileName, False)
End If
End Sub
Yes is it true internal will be betterI don't think you need to root your phone. It may depend on which Android version that support external storage. My phone is not rooted and I usually develop my app to move the db file from asset to Internal and not external to reduce any problem with the storage permission.