【发布时间】:2017-09-29 14:32:01
【问题描述】:
我在自定义列表视图中使用 ("content://sms/inbox") 访问所有短信,目前我正在获取地址正文和 _id 现在我想从另一个活动中删除选定的短信请指导我,我是 andorid 的初学者 这是我的主要活动,但我想从另一个活动中删除选定的短信
Uri uri = Uri.parse("content://sms/");
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(uri, null, null, null, null, null);
if(cursor !=null && cursor.moveToFirst()){
do{
// name = getContactName(address);
tid= cursor.getString(cursor.getColumnIndexOrThrow("_id"));
address = cursor.getString(cursor.getColumnIndexOrThrow("address"));
body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
if(name==null) {
list.add(new mybean("" + address, "" + body,""+tid));
}
else{
list.add(new mybean("" + name, "" + body,""+tid));
}
my =new myadapter(this,list);
lv.setAdapter(my);
}while(cursor.moveToNext());
}
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
Intent intent =new Intent(MainActivity.this,Main2Activity.class);
intent.putExtra("delete",list.get(pos).getDel());
intent.putExtra("sms",list.get(pos).getNumber());
intent.putExtra("smsmsg",list.get(pos).getMsg());
startActivity(intent);
}
});
【问题讨论】:
-
自 KitKat (4.4) 以来,您的应用无法从 Provider 中删除 SMS,除非它是当前的默认消息应用。
-
是的,我现在理解逻辑谢谢
标签: android