i want to read all sms from inbox and check for a particular keyword.I developed this code.but it doesn't produce the desired result.please suggest me corrections to be made.
public void onClick(View arg0 ){
Uri uri = Uri.parse("content://sms/inbox");
ContentResolver content = getContentResolver();
Cursor c = content.query(uri,new String[] { "_id","address","body","person"}, null, null, null);
if(c.getCount() > 0)
{
while(c.moveToNext())
{
colName = colName + c.getString(c.getColumnIndex("body")) + "\n";
if(colName.contains("hai"))
textview1.setText("present");
else
textview1.setText("not present");
}
}
}
});
}