我希望能够读取系统的 SMS 内容提供程序。基本上我想制作一个短信应用程序,但只有在我能看到过去的线程等情况下才有用。
似乎有一个内容提供者,但我找不到它的文档 - 有人知道那在哪里吗?
谢谢
-------- 编辑 ------------
好的,我找到了获取短信收件箱提供程序的方法,我只是转储了该提供程序中的所有列名,如下所示:
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = context.getContentResolver().query(uriSms, null,null,null,null);
// column names for above provider:
0: _id
1: thread_id
2: address
3: person
4: date
5: protocol
6: read
7: status
8: type
9: reply_path_present
10: subject
11: body
12: service_center
13: locked
我只是从我在网上找到的随机线程中拼凑出来的,我真的很想知道这一切都记录在哪里(如果有的话)?
再次感谢
最佳答案
除此之外,您还可以使用以下代码查看短信内容提供商中的字段列表:
private void displaySmsLog() {
Uri allMessages = Uri.parse("content://sms/");
//Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same
Cursor cursor = this.getContentResolver().query(allMessages, null,
null, null, null);
while (cursor.moveToNext()) {
for (int i = 0; i < cursor.getColumnCount(); i++) {
Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
}
Log.d("One row finished",
"**************************************************");
}
}
关于android - 如何使用短信内容提供商?文档在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1976252/