获取详细的短信其ID的Andr​​oid [英] Get SMS Details From its ID Android

查看:132
本文介绍了获取详细的短信其ID的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的手机短信详细信息(数字,文本正文,未来的时间);我只知道短信的ID。 我可以查询到内容://短信这个ID,并得到详细信息?

I want to get Details of SMS(Number, Text Body, Time of coming); And i only know the id of sms. Can i query to "content://sms" with this id and get details?

目前,我可以做一个循环,并查询每个消息并获得详细信息。但是,当你要得到一个短信细节10倍的1000条短信,是不是有效率..... 希望大家理解这个问题。 感谢名单

At the moment i can make a loop and query for every message and get details. But that is not efficient when you have to get single sms details 10 times from 1000 sms..... Hope you understand the problem. Thanx

推荐答案

我找出我自己,但我花了一些时间,按照code对我的作品:

I figure out my self but took me some time, Following code works for me:

        Uri myMessage = Uri.parse("content://sms/");
        ContentResolver cr = getContentResolver();
        Cursor c = cr.query(myMessage, new String[] { "_id", "address", "date", "body","read" },"_id = "+smsID, null, null);

        c.moveToFirst();

        Number = c.getString(c.getColumnIndexOrThrow("address")).toString();

        ReadStatus = c.getString(c.getColumnIndex("read"));
        Body = c.getString(c.getColumnIndexOrThrow("body")).toString();

        c.close;

我失踪了条件,将光标移动到第一位。希望有人能找到它有帮助。

I was missing the condition and moving the cursor to first. Hope someone could find it helpfull.

这篇关于获取详细的短信其ID的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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