让未读短信计数的更快的方法? [英] A faster way of getting unread SMS count?

查看:205
本文介绍了让未读短信计数的更快的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String address = 0123456789;

Cursor unreadcountcursor = getContentResolver().query(Uri.parse("content://sms/inbox"),
new String[]{}, "read = 0 and address='"+address+"'", null, null);

int count = unreadcountcursor.getCount();

难道没有得到它的一个更快的方法?因为这code是非常沉重的,当你必须采取计数多的数字来执行,需要花费大量的时间来加载。有另一种方式,假设该code将在一个while循环。我知道,在适配器使用,这是更快的和可能的,但与适配器的问题是,我必须滚动槽列表,并返回计数得到更新和notifyDataSetChanged()不会做这种事。

Isn't there a faster way of getting it? Because this code is very heavy to execute when you have to take the count for many numbers, it takes a lot of time to load. Is there another way, supposing that this code will be in a while loop. I know that using this in the adapter is faster and possible, but the problem with the adapter is that I have to scroll trough the list and return for the count to get updated and notifyDataSetChanged() doesn't do anything for this.

什么是最好的解决办法?

What would be the best solution?

感谢。

推荐答案

我不知道这将不遗余力大部分设备的时间,但你的 - definitly:

I am not sure this will spare much of device time, but of yours - definitly:

 Cursor countCursor = getContentResolver().query(CONTENT_URI,
                "count(*) AS count",
                null,
                null,
                null);

        countCursor.moveToFirst();
        int count = countCursor.getInt(0);

从<被引href=\"http://stackoverflow.com/questions/468211/how-do-i-get-the-count-in-my-content-provider\">here

这篇关于让未读短信计数的更快的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆