I want to compare incoming sms numbers with database saved number. if they are same then show a Toast. It works fine for simple numbers like 9 or any others but not with + operator.
When we recieved a message from a number it consists of country code like for pakistan +92XXXXXXXXXX. I've saved it to database but when message recieved with the same number then it doesn't match.
I checked on emulator it works fine for simple number like message from 9 etc. but not with + operator. kidnly help.
My database tabe:
// Create statement for block_list table
public static final String CREATE_TABLE_BLOCK_LIST = "CREATE TABLE " + TABLE_BLOCK_LIST
+ "(" + ID_BLOCK_LIST + " INTEGER PRIMARY KEY AUTOINCREMENT DEFAULT 0,"
+ ORIGINATING_ADDRESS_BLOCKlIST + " TEXT,"
+ TIME_BLOCK_LIST + " TEXT)";
comparing statement:
// Select all Blocked Numbers
public Cursor compareToBlockList(String originatingAddress){
Cursor cursor = null;
try {
SQLiteDatabase db = this.getWritableDatabase();
cursor = db.rawQuery("SELECT " + ORIGINATING_ADDRESS_BLOCKlIST + " FROM " + TABLE_BLOCK_LIST
+ " WHERE " + ORIGINATING_ADDRESS_BLOCKlIST + "=" + originatingAddress, null);
} catch (Exception e){
Log.d("compare to Block list", " is" + e.getMessage());
}
return cursor;
}
calling function:
Cursor cursor = dbManagement.compareToBlockList(originatingAddress);
cursor.moveToFirst();
String number = cursor.getString(cursor.getColumnIndex(dbManagement.ORIGINATING_ADDRESS_BLOCKlIST));
Toast.makeText(context, "found", Toast.LENGTH_LONG).show();
database value:
Aucun commentaire:
Enregistrer un commentaire