How can I put date condition in below code (Cursor ) .. I want to read SMS only for last 10 days . Epoch Seconds for 10 Days : 864000.
and secondly how to run this in faster way .. It is reading sms very slow .. Do we have any index column which can be used and if yes how ?
B4X:
Sub GetSMS(SMSstr As String) As List
Dim SMSList As List
Dim Msgid,MsgDt As String
Dim MsgFrom , MsgBody As String
SMSList.Initialize
Dim ur As Uri
ur.Parse("content://sms")
Dim crsr As Cursor = cr.Query(ur,Array As String("_id","date","address","body"),"address = ?", Array As String(SMSstr),"_id")
Log("Number of columns = " & crsr.ColumnCount)
Log("Number of SMS = " & crsr.RowCount)
crsr.Position = 0
For r = 0 To crsr.RowCount -1
crsr.Position = r
Msgid = crsr.GetInt("_id")
MsgDt = crsr.GetLong("date")
MsgFrom = crsr.GetString("address")
MsgBody = crsr.GetString("body")
SMSList.Add (Msgid& "!"&MsgDt&"!"&MsgFrom&"!"&MsgBody)
Next
crsr.Close
Return SMSList
End Sub
and secondly how to run this in faster way .. It is reading sms very slow .. Do we have any index column which can be used and if yes how ?