dothedos
dothedos

Reputation: 169

How can i get a specific row in my database using id?

I have a database with columns :id,question,answer1. I want the user to enter the id and return the specific question everytime. I have a problem using the query!Can anyone help?

Upvotes: 0

Views: 1054

Answers (1)

MByD
MByD

Reputation: 137322

Assuming you want the fields of COLUMN1 and COLUMN2, and id is the row-ID:

SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, new String[] { COLUMN1, COLUMN2
                }, ID + "=?", new String[] { String.valueOf(id) }, null, null, null, null);

Upvotes: 3

Related Questions