PiyushMishra
PiyushMishra

Reputation: 5773

sqlite query related issue

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.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;

}

Upvotes: 1

Views: 142

Answers (1)

Matthew
Matthew

Reputation: 44919

Try something like:

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

Upvotes: 1

Related Questions