android--短信查询(4)
"body",
"type"
};
StringBuilder str=new StringBuilder();
try{
Cursor myCursor = managedQuery(Uri.parse("content://sms"),
projection,
null, null , "date desc");
str.append(processResults(myCursor));
}
catch (SQLiteException ex)
{
Log.d(LOG_TAG, ex.getMessage());
}
return str.toString();
}
/**
* 处理短信结果
*
*/
private StringBuilder processResults(Cursor cur) {
// TODO Auto-generated method stub
StringBuilder sb=new StringBuilder();
if (cur.moveToFirst()) {
String name;
String phoneNumber;
String sms;
int type;
int nameColumn = cur.getColumnIndex("person");
int phoneColumn = cur.getColumnIndex("address");
int smsColumn = cur.getColumnIndex("body");
int typeColum = cur.getColumnIndex("type");
do {
// Get the field values
name = cur.getString(nameColumn);
phoneNumber = cur.getString(phoneColumn);
sms = cur.getString(smsColumn);
type = cur.getInt(typeColum);
System.out.println("..................................");
System.out.println("name"+name);
System.out.println("type"+type);
System.out.println("phoneNumber"+phoneNumber);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>