MMS-SMS数据库的_id列

时间:2015-03-05 15:04:08

标签: android android-sqlite

我正在访问Android MMS-SMS数据库:

Uri.parse("content://mms-sms/conversations?simple=true");
ContentResolver contentResolver = getContentResolver();
String[] projection = {"_id"};
Cursor cursor = contentResolver.query(uri, projection, null, null, null);

//Is the id the same as the id in corresponding SMS or MMS table?
long id = cursor.getLong(cursor.getColumnIndex("_id"));

我的问题很简单,“_id”列是否包含相应表格的相同ID值(对于短信"content://sms";对于MMS "content://mms")?如果不是,我如何从我得到的cursor获取短信或彩信表中的消息ID?

我想要做的是我想使用此ID查询相应的短信或彩信表。

2 个答案:

答案 0 :(得分:1)

你想要从“content:// mms-sms / conversations?simple = true”中的“_id”列获取mms-sms 尝试

Account

“id”是值“_id”列。

答案 1 :(得分:-1)

我认为你是以错误的方式做到这一点。您应该将关于短信的想要的值添加到projection,就像那样;

String[] projection = {"Conversations._ID"}; 

然后你可以用sms id:

long id = cursor.getLong(0);

如果您想从Sms获取其他信息,请将密钥添加到projection,如:

String[] projection = {"Conversations._ID", "Conversations.ADDRESS", "Conversations.BODY"}; 

然后;

long id = cursor.getLong(0);
String address = cursor.getString(1); // tel number
String body = cursor.getString(2); // content of message

修改:您还应检查您的uri并尝试:

Cursor cursor = contentResolver.query(Conversations.CONTENT_URI, projection, null, null, null);
祝你好运。

相关问题