Android Question How to refresh SQlite Database

Makumbi

Well-Known Member
Licensed User
Please help i have just add new field to my previous table but they are not detected by android B4a what can i do to make them detectable
B4X:
Logger connected to: emulator-5554
--------- beginning of main
--------- beginning of system
** Receiver (pushservice) OnReceive **
Cannot start from a receiver in debug mode.
ExecuteHtml: SELECT Names,Class As CS,Stream As Str,Amount,Dates FROM student
** Activity (main) Pause, UserClosed = false **
** Activity (eventsdata) Create, isFirst = true **
ExecuteHtml: SELECT Events,Class As CS,Stream As Str,Dates FROM Eventsinfo
** Activity (eventsdata) Resume **
--------- beginning of crash
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT Names,Class As CS,Stream As Str,Amount,Dates FROM student
** Activity (main) Pause, UserClosed = false **
** Activity (linkupdates) Create, isFirst = true **
** Activity (linkupdates) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
(JSONTokener)  at character 0 of [{"CustomerId":"05-00001","Comments":"Jana Sports Day Please Come Early","Dates":"\/Date(1543525200000)\/","Status":null,"Class":"P1","Stream":null,"Term":null,"Years":null}]
Account: 05-00001
Events: Jana Sports Day Please Come Early
Class: P1
Stream: null
Years: null
Term: null
11/30/2018
30/11/2018
Error occurred on line: 316 (Linkupdates)
android.database.sqlite.SQLiteException: table Eventsinfo has 5 columns but 8 values were supplied (code 1): , while compiling: INSERT INTO Eventsinfo VALUES('05-00001','Jana Sports Day Please Come Early','P1','null','30/11/2018','1','null','null')
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
    at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
    at anywheresoftware.b4a.sql.SQL.ExecNonQuery(SQL.java:74)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:778)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:358)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:365)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 268 (Main)
android.database.sqlite.SQLiteException: no such table: Register (code 1): , while compiling: SELECT ID FROM Register
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
    at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:211)
    at de.amberhome.slidemenuexample.main._activity_resume(main.java:631)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at de.amberhome.slidemenuexample.main.afterFirstLayout(main.java:110)
    at de.amberhome.slidemenuexample.main.access$000(main.java:17)
    at de.amberhome.slidemenuexample.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
just add new field to my previous table but they are not detected by android B4a
Where did you add the new fields to? On the database on your pc?

If you changed the DB on windows then you need to put it into files folder AND copy it to use the new db but be aware that you´ll lost any data in the DB as you are overwriting the old database already used.

If you change a Database then you need to do this changes on the database on Android TOO. You need to have some kind of versioning system in your android.

So in this case you added 3 fields. But you did not added them in android to the database too. There must run 3 ALTER TABLE queries like you run them on windows (or whereever you did the changes).

Search google on SQLite versioning. Don´t expect me to post some code for you. Google will find a lot of examples.
 
Upvote 0
Top