0

Is there a way for selecting the rowid from table using SQLiteDatabase instance

Cursor websiteCursor= mDatabaseManipulator.query(mTableName, null, COLUMN_WEBSITENAME+"='"+websiteName+"'", null, null, null, null);

Above cursor doesn't get the rowid. The doc says passing null in second argument will return all columns. But rowid is not returned.

I m getting rowid using rawQuery.

Cursor websiteCursor = mDatabaseManipulator.rawQuery("Select rowid _id, * from " + mTableName + " where " + COLUMN_WEBSITENAME + " = '" + websiteName +"'", null);
2
  • 1
    How do you know the rowid is not returned? Note that rowid is just an alias for the integer primary key column if there's one. Commented Dec 30, 2013 at 12:07
  • In your raw query, you do not get the rowid with * but have to list it explicitly, too. Commented Dec 31, 2013 at 13:00

1 Answer 1

1

I think there is some problem in the way that you are implementing the cursor, try this :-

Cursor websiteCursor= mDatabaseManipulator.query(mTableName, new String[]{rowid_id}, COLUMN_WEBSITENAME+" =? ", new String[]{websiteName}, null, null, null);
Sign up to request clarification or add additional context in comments.

Comments

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.