For a project I have to make an sms application on a tablet with SIM. I am able to send a sms and to receive a sms, but when I use Content Resolver to acces "content://sms/inbox" my cursor has no data. Anyone has an idea of what could be the problem?
Here is my code to read sms from inbox:
private List<Sms> getSms() {
List<Sms> smsList = new ArrayList<Sms>();
Uri uri = Uri.parse("content://sms/inbox");
Cursor c= mContext.getContentResolver().query(uri, null, null ,null,null);
Log.d("stackoverflow", "Number of sms: " + c.getCount());
while(c.moveToNext()) {
Sms sms = new Sms(c.getString(c.getColumnIndexOrThrow("address")).toString(), c.getString(c.getColumnIndexOrThrow("body")).toString());
smsList.add(sms);
}
c.close();
return smsList;
}
The Log in the code above returns zero, even when I just sent an sms to the Tablet.
Thanks in advance!