在Android中检查Sqlite中的现有记录?

时间:2011-04-12 14:40:38

标签: android database sqlite where-clause

Hii人

我试图在插入记录之前检查android中的现有记录。我得到一个异常,当我检查logcat它说它的语法错误。需要一些Urget帮助这些家伙

感谢

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;

1 个答案:

答案 0 :(得分:3)

变化:

"SELECT 1 FROM"

"SELECT 1 FROM "