我正在使用 Sqlite 数据库并为行存储空值。我正在使用此代码在数据库中存储空值:
ContentValues values = new ContentValues();
values.put(KEY_NAME,"");
values.put(KEY_PH_NO,"");
values.put(KEY_FOLDER_NAME, contact.getFolderName());
values.put(KEY_FolderAddress, contact.getParentFolderAddress());
values.put(KEY_TIME, contact.getTime());
values.put(KEY_DATE, contact.getDate());
我正在使用以下查询来检索具有空值的数据库条目:
String selectQuery = "SELECT * FROM " + TABLE_CONTACTS + " WHERE "+KEY_FolderAddress+" ='"
+FileAddress+"'"+" AND "+KEY_FOLDER_NAME+" ='"+FileName+"'"+" AND "+KEY_DATE+" ='"+"0"+"'"
+" AND "+KEY_PH_NO+" ='"+""+"'"+" AND "+KEY_NAME+" ='"+""+"'";
但是我在检索空值时遇到了这个异常:
12-25 11:52:40.531: E/Exception:(1990): android.database.sqlite.SQLiteException: unknown error: , while compiling: SELECT * FROM rules WHERE folderaddress ='/sdcard/Velosys/a' AND folder_name ='a' AND date ='0' AND phone_number ='' AND name ='' Exception occured in getTimeOfTheFolderFromContact() of DatabaseHandlerRule.java
我进行了很多搜索,但没有得到解决方案。请帮助我找到从 sqlite 数据库中检索空值的正确方法。提前致谢
编辑:
I am storing 2 entries with empty values i.e KEY_NAME and KEY_PH_NO
这是表格格式:
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY, " +KEY_NAME+" TEXT, "+ KEY_PH_NO + " TEXT, "
+KEY_FOLDER_NAME+" TEXT, "+ KEY_FolderAddress + " TEXT, "+KEY_TIME + " TEXT, "+KEY_DATE+" TEXT "+")";
db.execSQL(CREATE_CONTACTS_TABLE);