EGHDK
EGHDK

Reputation: 18130

SQLITE fetch statement in Android not working

I have everything working in my DBHelper class except for my fetch statement. I get a red line under query. What am I doing wrong here?

public Cursor fetchAllItems() {
        return mDb.query(DATABASE_TABLE, new String[] { KEY_ITEM, KEY_PRIORITY,
                KEY_ROWID }, null, null);
    }

Upvotes: 1

Views: 89

Answers (3)

Lawrence Choy
Lawrence Choy

Reputation: 6108

public Cursor fetchAllItems() {
    return mDb.query(DATABASE_TABLE, new String[] { KEY_ITEM, KEY_PRIORITY,
        KEY_ROWID }, null, null, null, null, null);
}

You may also read the API reference here regarding database. You can see all the available functions there.

Upvotes: 0

waqaslam
waqaslam

Reputation: 68177

Seems like you are missing to provide some extra null. See below:

public Cursor fetchAllItems() {
   return mDb.query(DATABASE_TABLE, new String[] {KEY_ITEM, KEY_PRIORITY,
          KEY_ROWID}, null, null, null, null, null);
}

For more info, read the docs.

Upvotes: 2

Ankit HTech
Ankit HTech

Reputation: 1893

public Cursor fetchAllItems() {
return mDb.query("", new String[] { KEY_ITEM, KEY_PRIORITY,
        KEY_ROWID }, "", null, "", null, null);

}

This will work

Upvotes: 0

Related Questions