1

Error

FATAL EXCEPTION: main
Process: com.appmaster.akash.messageplus, PID: 6468
java.lang.IllegalArgumentException: Empty values
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1545)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1525)
at com.appmaster.akash.messageplus.Chat$8.onDataChange(Chat.java:783)
at com.google.android.gms.internal.zzduz.zza(Unknown Source:13)
at com.google.android.gms.internal.zzdwu.zzbvb(Unknown Source:2)
at com.google.android.gms.internal.zzdxa.run(Unknown Source:65)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
12-19 15:11:35.658 1957-2011/system_process E/memtrack: Couldn't load memtrack module

Code

 if(mSeen!=null && mSeen.equals("No")) {
        if (mTime < seen)
             contentValues.put(KEY_SEEN, "Yes"); //Change the value of newData(which is actually your old value) by incrementing
                    long returnVariable = db.update(TABLE_CHAT_DATA, contentValues, null, null);
             if (returnVariable == -1) {
                    Toast.makeText(getApplication(), "Nope", Toast.LENGTH_LONG).show();
                        //-1 means there was an error updating the values
             } else {
                    Toast.makeText(getApplication(), "SEEEEEEN", Toast.LENGTH_SHORT).show();
             }

}

The error is on the update line... I don't understand this because the data is right there and still showing empty values. Can someone help me out, please

1
  • what happens if you change db.update to db.updateWithOnConflict and set CONFLICT_IGNORE as its flag? Commented Dec 19, 2018 at 10:01

1 Answer 1

2

Put brackets around the content of your first if-statement. The brackets are missing so the second line always executes, regardless of the if (I'm assuming that you don't enter values earlier for contentValues).

                  if (mTime < seen) { //// HERE
                        contentValues.put(KEY_SEEN, "Yes"); //Change the value of newData(which is actually your old value) by incrementing
                    long returnVariable = db.update(TABLE_CHAT_DATA, contentValues, null, null);
                   } /// AND HERE
                    if (returnVariable == -1) {
                        Toast.makeText(getApplication(), "Nope", Toast.LENGTH_LONG).show();
                        //-1 means there was an error updating the values
                    } else {
                        Toast.makeText(getApplication(), "SEEEEEEN", Toast.LENGTH_SHORT).show();
                    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.