0

I am using sqlite database for android development. I should not have the repeatation of records with a same username so that i need to check is that username is existing or not in the database. For that i got a solution called count query. Can i get how to use the count query in sqlite.

1 Answer 1

1

You can use rawQuery, something like:

final String SQL_STATEMENT = "SELECT COUNT(*) FROM users WHERE uname=?";

private void someMethod() {
    Cursor c = db.rawQuery(SQL_STATEMENT, new String[] { username });
    ...
}
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.