I followed this for updating my database: Android SQLite: Update Statement
It works good, but when I run my application, it crashes by saying: unfortunately your app has stopped working.
Here is the output of my log:
android.database.sqlite.SQLiteException: no such table: users (code 1): , while compiling: UPDATE users SET total_usage=? WHERE email =myemail
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1113)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:690)
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.updateWithOnConflict(SQLiteDatabase.java:1688)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1636)
at com.example.userX.theneckoptimizer.library.DatabaseHandler.updateUser(DatabaseHandler.java:92)
at com.example.userX.theneckoptimizer.background$1.onFinish(background.java:101)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
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:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
I start calling the update function when onFinish() is executed:
public void onFinish() {
MyActivity.amountOfVibrations= MyActivity.amountOfVibrations+ 1;
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(500); //0.5 seconds of vibration
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
db.updateUser(RegisterActivity.email, "123456");
} // email = myemail
The db.UpdateUser functions is as follows:
public void updateUser(String email, String total_usage) {
SQLiteDatabase db = this.getWritableDatabase();
String strFilter = "email =" + email;
ContentValues args = new ContentValues();
args.put(KEY_TOTAL_USAGE, total_usage);
db.update("users", args, strFilter, null);
}
I try to update a row: total_usage, where column: email.
Updating some data is the most important part in my application.
Why the log gives this output:
while compiling: UPDATE users SET total_usage=? WHERE email =myemail
I really hope someone can help me. Im trying more than 10 hours to solve this issue..