0
public ArrayList < PatientInfo > getAllPatients(String username) {
    ArrayList < PatientInfo > patients = new ArrayList < PatientInfo > ();

    open();

    Cursor cursor = db.query(UserTable, null, null, null, null, null, AccessedDate);
    while (cursor != null && cursor.moveToNext()) {
        try {

        } catch (Exception ex) {
            //Log.e("XXX", ex.getMessage());
        }
    }
    if (cursor != null)
        cursor.close();
    close();

    Collections.reverse(patients);
    return patients;
}

I am getting username as argument in my method, how can i query out my table based on username and get the user specific result.

1 Answer 1

2

As you can see from the documentation, the third and fourth parameters to query() are the selection and selection args.

So you want something like this:

 Cursor cursor = db.query(UserTable, null, 
                          "username=?", new String[] {username}, 
                          null, null, AccessedDate);

Edit the third parameter as needed to match the actual name of the relevant column in your table.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.