How to get the number of sent SMS messages between specific dates in android -
is there way retrieve number of sent sms messages between specific dates in android?
i prefer officially supported sdk functionality, stating in answer whether part of official sdk helpful.
i aware of this stack overflow question seems use not officially supported android.provider.telephony.sms_received , content://sms/sent, rather not use (please correct me if i'm wrong being unsupported).
i know old question, came across , spotted unanswered. please not downvote me because of it. maybe need answer.
all have query phone content provider (i used calllog.calls constants instead hardcoded strings 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 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 case have supply clause make selection on projection. need convert bounds of dates you've mentioned in miliseconds (get date , convert ms). make sure pattern corresponds "dd-mm-yy".
the clause should like:
string = calllog.calls.date+"<"+frist_bound_in_ms + " , "+ calllog.calls.date + "< " + second_bound_in_ms; which take final form of our query: select date sms_content date < 'firstbound' , date < 'second bound'
modify uri smscontenturi = uri.parse("content://sms/"); adding end of "content://sms/" sent or inbox "content://sms/sent" or "content://sms/inbox", regarding box want query. cheers.
Comments
Post a Comment