ibra939 Active Member Licensed User Longtime User Apr 8, 2016 #1 shows problem saving to sql data the following screen
mangojack Expert Licensed User Longtime User Apr 9, 2016 #21 ibra939 said: if i deleted how is it work ? where will save data? Click to expand... 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 .. Attachments TestSQL.zip TestSQL.zip 10.7 KB · Views: 302 Upvote 0
ibra939 said: if i deleted how is it work ? where will save data? Click to expand... 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 ..
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #22 mangojack said: 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 .. Click to expand... i delete db but i still get error what happen ? Upvote 0
mangojack said: 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 .. Click to expand... i delete db but i still get error what happen ?
mangojack Expert Licensed User Longtime User Apr 9, 2016 #23 ibra939 said: i delete db but i still get error what happen ? Click to expand... Sorry .. Just noticed the New error java.io.FileNotFoundException: /mnt/sdcard/Android/data/b4a.example/files/savedata.db: open failed: EACCES (Permission denied) Click to expand... Change all File.Dir references to .. File.DirInternal (where you app is) from Lolipop there is an permission issue try to save to external sd card. Upvote 0
ibra939 said: i delete db but i still get error what happen ? Click to expand... Sorry .. Just noticed the New error java.io.FileNotFoundException: /mnt/sdcard/Android/data/b4a.example/files/savedata.db: open failed: EACCES (Permission denied) Click to expand... Change all File.Dir references to .. File.DirInternal (where you app is) from Lolipop there is an permission issue try to save to external sd card.
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #24 mangojack said: 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. Click to expand... but is every think fine with code only that permission problem? Upvote 0
mangojack said: 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. Click to expand... but is every think fine with code only that permission problem?
mangojack Expert Licensed User Longtime User Apr 9, 2016 #25 ibra939 said: but is every think fine with code only that permission problem? Click to expand... 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. Upvote 0
ibra939 said: but is every think fine with code only that permission problem? Click to expand... 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.
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #26 mangojack said: 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. Click to expand... i change but still same issue Upvote 0
mangojack said: 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. Click to expand... i change but still same issue
mangojack Expert Licensed User Longtime User Apr 9, 2016 #27 ibra939 said: i change but still same issue Click to expand... Can you upload that project .. Upvote 0
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #28 why is writing????? no such table: setting: , while compiling: INSERT INTO setting VALUES (Null,?,?) Attachments a2.zip a2.zip 10.7 KB · Views: 284 Upvote 0
mangojack Expert Licensed User Longtime User Apr 9, 2016 #29 ibra939 said: why is writing????? no such table: setting: , while compiling: INSERT INTO setting VALUES (Null,?,?) Click to expand... You did not follow instructions above to change your code ... See post #17. Your Code Code: 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 Should be ... Code: 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. *** Uninstall old app first OR delete existing blank db on first run ! Also Please study the Starter Service which would be best place for above code (see uploaded project #21) Upvote 0
ibra939 said: why is writing????? no such table: setting: , while compiling: INSERT INTO setting VALUES (Null,?,?) Click to expand... You did not follow instructions above to change your code ... See post #17. Your Code Code: 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 Should be ... Code: 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. *** Uninstall old app first OR delete existing blank db on first run ! Also Please study the Starter Service which would be best place for above code (see uploaded project #21)
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #30 as you say i do but same issue but in my phone work saving data but not view data: LogCat connected to: emulator-5554 ** Service (starter) Create ** ** Service (starter) Start ** ** Activity (main) Create, isFirst = true ** main_activity_create (java line: 334) android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1013) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:962) Upvote 0
as you say i do but same issue but in my phone work saving data but not view data: LogCat connected to: emulator-5554 ** Service (starter) Create ** ** Service (starter) Start ** ** Activity (main) Create, isFirst = true ** main_activity_create (java line: 334) android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1013) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:962)
mangojack Expert Licensed User Longtime User Apr 9, 2016 #31 ?? .. Could you try the attached . There should be no reason for it to fail. Attachments TestSQL 2.zip TestSQL 2.zip 10.8 KB · Views: 295 Upvote 0
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #32 mangojack said: ?? .. Could you try the attached . There should be no reason for it to fail. Click to expand... the problem was sql1.Initialize(File.DirInternal,"savedata.db",False) thanks for you solve work fine Upvote 0
mangojack said: ?? .. Could you try the attached . There should be no reason for it to fail. Click to expand... the problem was sql1.Initialize(File.DirInternal,"savedata.db",False) thanks for you solve work fine
mangojack Expert Licensed User Longtime User Apr 9, 2016 #33 ibra939 said: the problem was sql1.Initialize(File.DirInternal,"savedata.db",False) Click to expand... It was only the position of this line that caused a problem. Upvote 0
ibra939 said: the problem was sql1.Initialize(File.DirInternal,"savedata.db",False) Click to expand... It was only the position of this line that caused a problem.
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #34 mangojack said: It was only the position of this line that caused a problem. Click to expand... yes but i think if my phone have root will be working Upvote 0
mangojack said: It was only the position of this line that caused a problem. Click to expand... yes but i think if my phone have root will be working
aeric Expert Licensed User Longtime User Apr 9, 2016 #35 ibra939 said: yes but i think if my phone have root will be working Click to expand... 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. Upvote 0
ibra939 said: yes but i think if my phone have root will be working Click to expand... 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.
aeric Expert Licensed User Longtime User Apr 9, 2016 #36 The sqlite db is usually very small storage footprint (<1 Megabyte). I don't think app user mind to let it keep inside the internal storage. Here is how my app normally written when loading at Main activity. Code: 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 Upvote 0
The sqlite db is usually very small storage footprint (<1 Megabyte). I don't think app user mind to let it keep inside the internal storage. Here is how my app normally written when loading at Main activity. Code: 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
ibra939 Active Member Licensed User Longtime User Apr 9, 2016 #37 aeric said: 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. Click to expand... Yes is it true internal will be better Upvote 0
aeric said: 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. Click to expand... Yes is it true internal will be better