Android Question shows problem saving to sql data

ibra939

Active Member
Licensed User
Longtime User
shows problem saving to sql data the following screen
upload_2016-4-8_14-33-27.png
upload_2016-4-8_14-33-44.png
 

ibra939

Active Member
Licensed User
Longtime User
Also, your code would also help us!
LogCat connected to: B4A-Bridge: LGE LG-LS995
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
Error occurred on line: 60 (Main)
android.database.sqlite.SQLiteException: no such table: setting (code 1): , while compiling: INSERT INTO setting VALUES (Null,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:892)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:503)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1093)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:78)
at b4a.example.main._button1_click(main.java:422)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4443)
at android.view.View$PerformClick.run(View.java:18477)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Service (starter) Destroy **
** Activity (main) Pause, UserClosed = false **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 60 (Main)
android.database.sqlite.SQLiteException: no such table: setting (code 1): , while compiling: INSERT INTO setting VALUES (Null,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:892)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:503)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1093)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:78)
at b4a.example.main._button1_click(main.java:422)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4443)
at android.view.View$PerformClick.run(View.java:18477)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Installing file.
PackageAdded: package:b4a.example
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
android.database.sqlite.SQLiteException: no such table: setting (code 1): , while compiling: INSERT INTO setting VALUES (Null,?,?)
THIS is the error. There is no table setting in the database. check how you are initializing the database...
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
THIS is the error. There is no table setting in the database. check how you are initializing the database...

there is database setting.db and there are filed name id , title , txt
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
However. Upload a project (including database) and upload it. Without seeing your code and your databasestructure it is impossible to help you if you don´t give us enough informations.

glaskugel.jpg



I quit here as i don´t like to ask for any little pice of info.
Good luck
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
THIS is the error. There is no table setting in the database. check how you are initializing the database...

However. Upload a project (including database) and upload it. Without seeing your code and your databasestructure it is impossible to help you if you don´t give us enough informations.




I quit here as i don´t like to ask for any little pice of info.
Good luck

see this problem
 

Attachments

  • aaaa.png
    aaaa.png
    15.8 KB · Views: 164
Upvote 0

fixit30

Active Member
Licensed User
Longtime User
However. Upload a project (including database) and upload it. Without seeing your code and your databasestructure it is impossible to help you if you don´t give us enough informations.
As Donmanfred said, without seeing you actual code we are unable to help.

Are you sure you are connecting to the correct version of your database?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
if you insert and the id is autonumber then you don't need to pass it.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I guess that you have your original db in your assets, then you didn't copy it to somewhere you can read it, and finally initialize a db, with 'true' set to 'create if not exists'. This is an explanation for your error.
Of course, it is just a guess, and it would be helpful to post the line you're using to initialize your db, and if it was copied from assets and where.
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
thanks for all replay this from b4a i think i maked other program but not work ???? when i load by wireless and then install in my phone will then will open and not work will hide automatically

must i change the release or release (obfuscated ) ?

now all program what i make not work with me message " unforunatel , b4a example stopped
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
this the project can you check it
 

Attachments

  • a1.zip
    10.7 KB · Views: 155
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Although your db in Assets has a Table "setting' you dont get a chance to copy it if no db exists.

You are initializing the db first , with a TRue parameter (Create if it does not exist) but you don't then create the table.
Then you test if the db exists and if not then copy from Assets ( it will always exist)

Reverse your lines ..
B4X:
      'File.Delete(File.DirDefaultExternal,"savedata.db")

   If File.Exists(File.DirDefaultExternal,"savedata.db")=False Then
     File.Copy(File.DirAssets,"savedata.db",File.DirDefaultExternal,"savedata.db")
   End If

   sql1.Initialize(File.DirDefaultExternal,"savedata.db",False)' @@ Set to False .. the db should always exist.

Remember to first delete original blank db.

Also you Dim , test existence and Initialize Sql object in both Activities.
Do this once in the Starter Service.
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
Although your db in Assets has a Table "setting' you dont get a chance to copy it if no db exists.

You are initializing the db first , with a TRue parameter (Create if it does not exist) but you don't then create the table.
Then you test if the db exists and if not then copy from Assets ( it will always exist)

Reverse your lines ..
B4X:
      'File.Delete(File.DirDefaultExternal,"savedata.db")

   If File.Exists(File.DirDefaultExternal,"savedata.db")=False Then
     File.Copy(File.DirAssets,"savedata.db",File.DirDefaultExternal,"savedata.db")
   End If

   sql1.Initialize(File.DirDefaultExternal,"savedata.db",False)' @@ Set to False .. the db should always exist.

Remember to first delete original blank db.

Also you Dim , test existence and Initialize Sql object in both Activities.
Do this once in the Starter Service.

thanks for your replay
but the same problem i have showing error not work?


** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 43 (Main)
java.io.FileNotFoundException: /mnt/sdcard/Android/data/b4a.example/files/savedata.db: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:406)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:747)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:390)
... 23 more
** Activity (main) Resume **
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Did You Delete the db file first ?
 
Upvote 0

Similar Threads

Top