I know it is very old question, I just came across and spotted as unanswered. So please do not downvote me just because of it. Maybe someone will need this answer.
All you have to do is to query the phone content provider (I used CallLog.Calls
constants instead hardcoded strings for columns names)
String[] projection = { CallLog.Calls.DATE };
Uri smsContentUri = Uri.parse("content://sms/");
Cursor cursor = this.getContentResolver().query(smsContentUri , selection,where, null, null);
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yy");
cursor.moveToFirst();
Log.d("SMS COUNT", ""+cursor.getCount());
while(cursor.isAfterLast() == false){
Log.d("SMS DATE", ""+cursor.getString(cursor.getColumnIndex(CallLog.Calls.DATE))); //raw format of the date in milliseconds
long callDate = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE));
String dateString = format.format(new Date(callDate));
Log.i("SMS DATE",dateString);
cursor.moveToNext();
}
For your case all you have to do is to supply a where clause which will make selection over the projection. You need to convert bounds of dates you've mentioned in miliseconds (get the date and convert it to ms). Make sure your pattern corresponds to "dd-MM-yy"
.
The where clause should look like:
String where = CallLog.Calls.DATE+"<"+FRIST_BOUND_IN_MS + " AND "+ CallLog.Calls.DATE + "< " + SECOND_BOUND_IN_MS;
which take us to the final form of our query: SELECT date FROM sms_content WHERE date < 'firstbound' AND date < 'second bound'
Modify Uri smsContentUri = Uri.parse("content://sms/");
adding to the end of the "content://sms/"
sent or inbox to get "content://sms/sent"
or "content://sms/inbox"
, regarding which box you want to query.
Cheers.