貌似谷歌把threads类给屏蔽起来了!
他们系统的软件可以用,我们自己写的就看不到这个类,不知道为什么,
另外 读短信数据库的时候 threads表也没办法读到Threads.CONTENT_URI 这个URI的字符串是啥?
找了很久也找不到!哪位告诉给指点一下!
他们系统的软件可以用,我们自己写的就看不到这个类,不知道为什么,
另外 读短信数据库的时候 threads表也没办法读到Threads.CONTENT_URI 这个URI的字符串是啥?
找了很久也找不到!哪位告诉给指点一下!
解决方案 »
- android4.1.2,锁屏后休眠,横竖屏旋转,再唤醒,间歇性卡屏(刷新异常),求高人指点
- 安卓开启一个新线程就崩溃 大家来看看我错在哪里
- 懂phonegap的人进来,探讨下。Android程序调用Web程序。
- 有关android编译问题
- 没有继承ListActivity,ListView中的item如何实现点击响应?
- 如何把*.apk(下载的*.apk)放在android 模拟器上运行?
- 【Android】SQLite 数据库查询问题
- Android调用Axis2发布的Web Service不通问题
- Android Studio无法创建项目?
- 求大神帮忙看下错误点android.view.WindowManager$BadTokenException
- android用一张小图片覆盖background的一部分
- NDK里面socket connect总是返回-1
不过读取彩信发送者号码的我倒是找到了一种方法。。有同样需求的话可以看下该帖:
http://topic.csdn.net/u/20100611/12/aaf9f499-61de-45dd-8a47-4b5623369253.html
null, null, null, null);
Cursor cursorSendbox = getContentResolver().query(Uri.parse("content://sms/sent"),
null, null, null, null);
if(cursorSendbox != null){
//发件箱信息
for(cursorSendbox.moveToFirst();!cursorSendbox.isAfterLast();cursorSendbox.moveToNext()){
// String bodySend = cursorSendbox.getString(cursorSendbox.getColumnIndexOrThrow("body"));
String numberSend = cursorSendbox.getString(cursorSendbox.getColumnIndexOrThrow("address"));
}
收发是一样的方法,如果要获取更多的东西,使用getColumnName获取,有body,address等可以获得
如果担心阻塞UI,那数据搜索扔到一个子线程中去处理,处理完后发个handler消息来通知更新UI
* 删除某条短信,条件是短信的id
* 注意:该操作会删除手机数据库中的相应数据。
*/
public boolean deleteASMSBy(SMS sms)
{
System.out.println(" deleteASMSBy "+sms.getId());
try
{
m_context.getContentResolver().delete(Uri.parse("content://sms/"+ sms.getId()), null, null);
}
catch (Exception e)
{
Toast.makeText(m_context, "删除失败"+sms.getId()+"\n"+e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
return false;
}
return true;
}
Threads.CONTENT_URI为content://mms-sms/conversations数据量大时候可以用SQL的统计函数:
getContentResolver().query(Uri.parse("content://sms/"), new String[]{"count(*) as count"}, null, null, null);
count(*) 是对某个字段求和?比如对会话求和 就知道这个人有多少个会话啦?
count(thread_id) 这么写?
要知道某个人发了多少封信,比如thread_id=3:
getContentResolver().query(Uri.parse("content://sms/"), new String[]{"count(*) as count"}, "thread_id=?", new String[]{"3"}, null);多少个人发过信:
getContentResolver().query(Uri.parse("content://sms/"), new String[]{"count(distinct(thread_id)) as count"}, "type='1'", null, null)
如果单纯想统计数据的话,在sms表中也可以查询。
我想统计 目前有多少个不同的thread_id,每个thread_id有多少个meassage,
做个类似短信箱列表的页面,能只查一个表搞定吗?
这个取出来的会话比较少,有很多没有取出来,不知道为何?
getContentResolver().query(Uri.parse("content://sms/"), new String[]{"* from threads --"}, null, null, null);
我看系统短信箱的源码是读的一个Threads.CONTENT_URI 这个URI
但 咱们程序导入不了
import android.provider.Telephony.Threads;
这个类啊!
难道非要读多次URI才能搞定?
getContentResolver().query(Uri.parse("content://sms/"), new String[]{" a.message_count, b.address from threads a, sms b where a.recipient_ids = b.thread_id group by b.address--"}, null, null, null);上面的SQL语句只是测试用的,具体你修改一下吧,按照这种方法应该能查出来。
还有个 address 的名字问题,
当前查询SMS库,没有联系人的名字,需要查联系人库才能得到做在一起查询能否实现?谢谢!
提示信息貌似是Failed to find provider for threads
大家帮帮忙啊!!急!
Cursor cursor = cr.query(Uri.parse("content://sms/inbox"), null, null, null, null);
while(cursor.moveToNext()) {
String body = cursor.getString(cursor.getColumnIndexOrThrow("body")).toString();往下不知道怎么写了,设置查询条件不知道怎么设.......请帮帮忙啊....谢谢......
即 threads 表 的字段 recipient_ids 是74 190 191 194 196 202 203 204
源码貌似说要更新
RecipientIdCache.updateNumbers(conv.getThreadId(), conv.getRecipients());
-------------------------------
但 RecipientIdCache 不知道怎么更新
Uri.parse("content://sms/"),
new String[] { "* from threads group by date--" }, null, null, null); 我在后面 date 后面加 desc 就报错了。。 我想降序 咋整?
那就读到内存 然后再写程序排序吧!