0

I am creating a project where I have to periodically check the number of sent SMS and MMS in that timer period. For example, number of sent SMS/MMS in last 15 minutes.

I have seen this post: How to use SMS content provider? Where are the docs? and Mark Murphy (CommonsWare) has mentioned not to use the SMS content provider because it is un-documented.

In the light of above, what can I do to achieve my goal?

@CommonsWare Can you please comment?

Community
  • 1
  • 1
Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59

1 Answers1

0

You could use a refactored version of this to get what you need, I think.

SAMPLE:

private int deleteMessage(Context context, SmsMessage msg) {
Uri deleteUri = Uri.parse("content://sms");
int count = 0;
Cursor c = context.getContentResolver().query(deleteUri, null, null,
        null, null);
    while (c.moveToNext()) {
    try {
        // Delete the SMS
        String pid = c.getString(0); // Get id;
        String uri = "content://sms/" + pid;
        count = context.getContentResolver().query(Uri.parse(uri),
                null, 
                "date('sentDate') - date('%M', '15') > date('now')", 
                null, 
                null);
    } catch (Exception e) {
    }
}
return count;

}

The SQL might be completely wrong, but something like this should work.

Community
  • 1
  • 1
Codeman
  • 12,157
  • 10
  • 53
  • 91
  • Yes, I may be able to use sms content provider to read sms data. But referring to my question, I would prefer not to use sms content-provider as it is undocumented as indicated by Mark Murphy. – Khurram Majeed Oct 30 '12 at 20:25
  • Pretty sure that's the only way to do so. – Codeman Oct 30 '12 at 20:31