java.lang.IllegalArgumentException:空值

时间:2018-12-19 09:49:20

标签: java android sqlite android-studio illegalargumentexception

错误

let hasClass = header.classList.contains('smaller');
header.classList.toggle('smaller', hasClass);

代码

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

错误在更新行上...我不明白这一点,因为数据就在那里,仍然显示空值。有人可以帮帮我吗

1 个答案:

答案 0 :(得分:1)

在第一个if语句的内容前后加上方括号。缺少方括号,因此无论是否执行第二行,总是执行第二行(我假设您不为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();
                    }