我有一些具有特定代码的sqlite数据。
String sql = "create table " + TABEL
+"( " + BaseColumns._ID+" integer PRIMARY KEY AUTOINCREMENT," + STARTTIME
+ " text," + ENDTIME + " text," + DURATION + " text,"
+ PHONEOPTION + " text," + MODE + " text);";
db.execSQL(sql);
Log.i("DATABASE ", "db created ");
我想获取其中duration列没有空数据的行。 我有一些代码,但它会获取其中的所有数据。
public Cursor getData() {
SQLiteDatabase sqlitedb = contactsdbHelper.getReadableDatabase();
Cursor cursor = sqlitedb.query(ContactsDatabaseHelper.TABEL, null,null,null, null,null, BaseColumns._ID + " DESC");
startManagingCursor(cursor);
return cursor;
}
答案 0 :(得分:1)
尝试类似:
Cursor cursor = sqlitedb.rawQuery(
"SELECT * FROM " + ContactsDatabaseHelper.TABEL + " WHERE " +
ContactsDatabaseHelper.DURATION + " NOT NULL", null);