I am trying fetch SMS message from specific sender but the problem is that sender has different codes something like "VM-Citi" or "AD-Citi". I would like to find out is it possible to query SMS only the sender has the keyword something like if it contains "citi"?
Right now I am doing the following:
Uri uriSMSuri = Uri.parse("content://sms/inbox");
String[] args = new String[]{ "VM-Citibk", "AD-Citibk" };
StringBuilder inList = new StringBuilder(args.length * 2); //for adding the ?
for(int i=0;i<args.length;i++)
{
if (i > 0)
{
inList.append(",");
}
inList.append("?");
}
cursor = getActivity().getContentResolver().query(uriSMSuri,new String[] {"*"}, "address IN ("+inList.toString()+")", args, "date desc");
if(cursor.getCount() > 0 && cursor != null)
{
while (cursor.moveToNext())
{
contactName = cursor.getString(cursor.getColumnIndex("address"));
snippet = cursor.getString(cursor.getColumnIndex("body"));
}
}
Right now I am having string [] args which has the sender info but is it possible to have args which says if sender contains "citi"?
Is it possible, if so how to apply that format to args?