Roses
Roses

Reputation: 59

Checking for an existing record in Sqlite in android?

Hii guys

Im trying to check for an existing record in android before inserting a record. i get an exception and when i check the logcat it says its a syntax error. need some Urget help with this guys

thanks

DbConnection dbConnection = new DbConnection(EnterDetails.this);
db = dbConnection.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT 1 FROM" + DbConnection.TABLE + " WHERE "+ DbConnection.C_MNUMBER + " = " +EditTextMobileNumber.getText().toString().trim(),null);
boolean flag = (cursor.getCount() > 0);
Toast.makeText(EnterDetails.this,"Record Found",Toast.LENGTH_LONG).show();
return false;

Upvotes: 0

Views: 786

Answers (1)

Cristian
Cristian

Reputation: 200080

Change:

"SELECT 1 FROM"

to

"SELECT 1 FROM "

Upvotes: 3

Related Questions