本文介绍了我想取和查看短信对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ContentResolver的CR = getContentResolver();
光标CUR = cr.query(Uri.parse(内容://短信/通话/),NULL,NULL,NULL,NULL);
不工作,为什么?
<使用-权限的Android:名称=android.permission.READ_SMS/>
权限已被添加。
10月八号至12日:56:39.188:ERROR / AndroidRuntime(377):android.database.sqlite.SQLiteException:由造成近,:语法错误:在编制:SELECT,身体片段从短信,(选择的thread_id AS group_thread_id,MAX(日期)AS group_date,COUNT(*)作为msg_count从短信GROUP BY的thread_id)AS组WHERE(sms.thread_id = groups.group_thread_id和sms.date = groups.group_date)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:143)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:111)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.content.ContentProviderProxy.bulkQuery(ContentProviderNative.java:279)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.content.ContentProviderProxy.query(ContentProviderNative.java:298)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.content.ContentResolver.query(ContentResolver.java:152)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在com.GetMessages.GetConversations $ FetchData.doInBackground(GetConversations.java:33)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在com.GetMessages.GetConversations $ FetchData.doInBackground(GetConversations.java:1)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在android.os.AsyncTask $ 2.call(AsyncTask.java:185)
十月八号至12日:56:39.188:ERROR / AndroidRuntime(377):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:256)
解决方案
终于得到了我需要的!
ContentResolver的ContentResolver的= getContentResolver();
最终的String []投影=新的String [] {*};
开放的我们的uri = Uri.parse(内容://彩信,短信/通话/);
光标查询= contentResolver.query(URI,投影,NULL,NULL,NULL);
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(Uri.parse("content://sms/conversations/"), null,null,null, null);
is not working why?
<uses-permission android:name="android.permission.READ_SMS" />
permissions have been added.
08-12 10:56:39.188: ERROR/AndroidRuntime(377): Caused by: android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: SELECT , body AS snippet FROM sms, (SELECT thread_id AS group_thread_id, MAX(date)AS group_date,COUNT(*) AS msg_count FROM sms GROUP BY thread_id) AS groups WHERE (sms.thread_id = groups.group_thread_id AND sms.date =groups.group_date)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:143)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:111)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.content.ContentProviderProxy.bulkQuery(ContentProviderNative.java:279)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.content.ContentProviderProxy.query(ContentProviderNative.java:298)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.content.ContentResolver.query(ContentResolver.java:152)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at com.GetMessages.GetConversations$FetchData.doInBackground(GetConversations.java:33)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at com.GetMessages.GetConversations$FetchData.doInBackground(GetConversations.java:1)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-12 10:56:39.188: ERROR/AndroidRuntime(377): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
解决方案
finally got what i needed!
ContentResolver contentResolver = getContentResolver();
final String[] projection = new String[]{"*"};
Uri uri = Uri.parse("content://mms-sms/conversations/");
Cursor query = contentResolver.query(uri, projection, null, null, null);
这篇关于我想取和查看短信对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!