我想从收件箱中读取所有短信并检查特定关键字。我开发了此代码。但它没有产生所需的结果。请建议我进行更正。
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");
}
}
}
});
}