今天在用SQLiteDatabase检查表中是否存在某个字段的时候遇到这个错误
Cursor cursor = db.rawQuery(existSql, new String[]{useraccount});
java.lang.IllegalArgumentException: the bind value at index 1 is null 意思是要搜索的字段为空, 一个是我太不小心了(-.=|||竟然绑定错控件),第二个是方法调错了(囧)
在用SQLiteDatabase查询有两种方法:
1.
Cursor cursor = db.query(TABLE_NAME, null,"account=?", new String[]{useraccount}, null, null, null);
while(cursor.moveToFirst)
2.
String existSql = "select * from "+TABLE_NAME+" where account=?"; Cursor cursor = db.rawQuery(existSql, new String[]{useraccount});
while(cursor.moveToFirst)
因为这次粗心大意..浪费了半天 -_-|||必须记录下来以此为鉴.