作为一个学院项目,我必须创建一个Android应用程序来搜索存储在设备中的SMS消息。就像。如果输入"hi",那么所有包含"hi“字的消息都会显示在屏幕上。我知道这是直接在新的Android版本,但现在我不能改变主题,我将有一个这样的应用程序,并完成它在2012年1月的第一周!
我在谷歌上搜索了两种方法:-
我需要建议哪种方法是合适的,哪些其他选择是可用的。以及如何将SMS数据库链接到Android搜索界面,并在屏幕上正确显示消息。期待您的建议和答案,如果您没有时间,请至少提供与上述问题相关的有用资源的链接!
发布于 2012-09-29 10:35:52
使用编辑框和搜索按钮作为GUI。在收件箱中搜索特定单词的主要代码是:
static Uri uri ;
Cursor c;
uri = Uri.parse("content://sms/inbox");
c = getContentResolver().query(uri, null, null ,null, "date DESC");
startManagingCursor(c);
String[] body = new String[c.getCount()];
if(c.moveToFirst()){
for(int i=0;i<c.getCount();i++){
body[i]= c.getString(c.getColumnIndexOrThrow("body")); //.toString()
item = check(body[i]);
c.moveToNext();
}
}
c.close();而检查功能是:
public ArrayList<String> check(String str)
{
boolean fullContainsSub = str.toUpperCase().indexOf(content.toUpperCase()) != -1;
if(fullContainsSub)
{
itemList.add(str);
}
return itemList;
}希望这能帮到别人!
https://stackoverflow.com/questions/8711760
复制相似问题