开发者

sqlite query related issue

开发者 https://www.devze.com 2023-02-16 08:04 出处:网络
I have certain sqlite data having the certain code. String sql = \"create table \" + TABEL +\"( \" + BaseColumns._ID+\" integer PRIMARY KEY AUTOINCREMENT,\" + STARTTIME

I have certain sqlite data having the certain code.

String sql = "create table " + TABEL
    +"( " + BaseColumns._ID+" integer PRIMARY KEY AUTOINCREMENT," + STARTTIME
    + " text," + ENDTIME + " text," + DURATION + " text,"
    + PHONEOPTION + " text," + MODE + " text);";

    db开发者_如何学C.execSQL(sql);
    Log.i("DATABASE ", "db created ");

and i want to fetch the rows where duration column having not null data. i have certain code but it fetch the all data in it.

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;

}


Try something like:

Cursor cursor = sqlitedb.rawQuery(
    "SELECT * FROM " + ContactsDatabaseHelper.TABEL + " WHERE " +
    ContactsDatabaseHelper.DURATION + " NOT NULL", null);
0

精彩评论

暂无评论...
验证码 换一张
取 消