• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Parse | Check for existing data

walla90

Lurker
Hello;

I'm currently working on a new Android app, part of the app code is to collect the users id number for each new user.

I search my life out to find a way to check if the user is already appear in the database.

I'm looking for a simple way to check if the user is exist and if so to do something else..

please help...
 
SELECT * FROM tablename WHERE USERID = 'whatever the user id is';

If you get any row returned, the used id is already in the database. (Leave out the tick marks around the user id if the field is numeric.)
 
For the love of all that is holy do not construct your SQL queries by hand! :)

at least bind your parameters with a question mark.... ?

[HIGH]Cursor cursor =
getReadableDatabase()
.rawQuery("select * from tablename where _id = ?",
new String[] { id }); [/HIGH]
 
Back
Top Bottom