1

I have one employee table which has column values

("store_loc_id","name","password","address_id","role_id",
"retailer_id").

I want to get the name and password from this table using cursor. how can i do??

1

2 Answers 2

1

Haven't check this code, but the idiom should be understandable.

Cursor cursor = db.query(...);
if(cursor !=null && cursor.moveToFirst()) {
   do {
     String name = cursor.getString(cursor.getColumnIndex("name"));
   } while (cursor.moveToNext());
}
Sign up to request clarification or add additional context in comments.

Comments

0
public Cursor getEmployee() {
    try {
        return db.query(employee, new String[] { "name", "password" },
                null, null, null, null, null);
    } catch (SQLException e) {
        Log.e("Exception on query", e.toString());
        return null;
    }
}


Cursor c = db.getEmployee();
    if (c == null) {
        // do nothing
    } else {
        if (c.getCount() > 0) {
            if (c.moveToFirst()) {
                do {
                    String Name = c.getString(0);
                    String Password = c.getString(1);
                } while (c.moveToNext());
            }
        } 
}

1 Comment

I need the values of user name and password. Bu using db.getValues() i want to get the values. But what i have to write inside the getValues() that i am not getting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.