0

I'd like to know if we can write a short boolean test which return true if sms/inbox is empty or not.

Something like Databse("content://sms/inbox")==null?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Olivier69
  • 1,561
  • 2
  • 10
  • 4

2 Answers2

3

Here's the code:

// Retrieve a Cursor pointing to the sms list and the size of it.
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = mContext.getContentResolver().query(uriSMSURI, null, null, null, null);
boolean ret = cur.getCount() > 0;

Remember to close the cursor afterwards.

Macarse
  • 91,829
  • 44
  • 175
  • 230
0

You should have a look at this , its not a simple one liner but it will give you the data you require. It seems there is no documented way to do this easily , you are going to have to do alot of manual work or hope someone has written a lib to do it all for you

Community
  • 1
  • 1
RC1140
  • 8,423
  • 14
  • 48
  • 71