I have implemented a custom SQLite database helper. I have a table containing sms messages. I query this table for entries from a particular phone number like so:
public Cursor getSmsForContact(String phoneNumber) throws SQLException {
phoneNumber = PhoneNumberUtils.stripSeparators(phoneNumber);
Cursor cursor =
db.query(DATABASE_TABLE, new String[] {
KEY_DATE,
KEY_BODY,
KEY_CONTACT,
KEY_TYPE,
KEY_ROWID,
KEY_MESSAGE_STATE
}, KEY_CONTACT + "=" + phoneNumber, null, null, null, null);
return cursor;
}
This method works fine for numbers that do not have a “+” in the front (indicating a country code). However, it always returns an empty cursor when phoneNumber has a “+” in the front. I’ve verified that the PhoneNumberUtils.stripSeparators() method does not remove the “+” sign. I’ve also verified that rows exist in the table which match the phone number which is being queried.
Thanks!
Try
Phone number is being interpreted as a number; you want it to be interpreted as a string