Get SMS Details From its ID Android

谁说我不能喝 提交于 2019-12-01 00:45:14
Farhan

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();

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

        String ReadStatus = c.getString(c.getColumnIndex("read"));
        String 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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!