1

First I wanted to check the password entered is specific to that person but when I wrote the code like this:

Cursor cursor = db.rawQuery("Select * from user where email=?", new String[] {email});
String num = cursor.getString(1);

the password is in second column. Then the code above provided

CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1 called.

Then I have changed the code to:

Cursor cursor = db.rawQuery("Select * from user where email=?", new String[] {email});
cursor.moveToFirst();
String num = cursor.getString(1);

Why did it worked second time but not the first time. Please explain how does the position of the cursor changes with calling the query and then again moving i tot first.

Thank You

0 Answers0