How can I compare a phone number from the getOriginatingAddress() to my custom contact listview? i want to change the status to "available" but it doesn't update my listview and still shows the default "not available". is it possible to use the ourDatabase.update() if what i am using as a condition which is "KEY_NUMBER = mNumber" is not a primary key? thanks for help in advance
public void updateStatusAvailable(String mNumber) throws SQLException
{
// TODO Auto-generated method stub
ContentValues cvUpdate = new ContentValues();
cvUpdate.put(KEY_STATUS, "AVAILABLE");
ourDatabase.update(DATABASE_TABLE, cvUpdate, KEY_NUMBER + "=" + mNumber, null);
}
Here is how i get the phone number of sender
public String aStatus = "available";
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
info = new GroupDb(context);
Bundle bundle = intent.getExtras();
Object[] pdusObj = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdusObj.length];
for (int i = 0; i<pdusObj.length; i++)
{
messages[i] = SmsMessage.createFromPdu ((byte[])
pdusObj[i]);
sender = messages[i].getOriginatingAddress();
}
for (SmsMessage msg : messages) {
if (msg.getMessageBody().contains("available")) {
info.open();
Toast.makeText(context.getApplicationContext(), "received sms from: " +sender,
Toast.LENGTH_SHORT).show();
info.updateStatusAvailable(sender);
info.close();
}//end if - available
if(msg.getMessageBody().contains("notavailable"))
{
}//end if - not available
}//end for
}// end onreceive
another thing i am concerned about is my contact list, if i entered the number as "09211234567", the originating address may return "+639211234567". i've tried it in an emulator and send it to the address "5556" but the getOriginatingAddress() returned something like "15555215556". how do i deal with that?