Query SMS
Requires READ_SMS
permission.
Add the following permission in your AndroidManifest.xml
getInboxSms()
Returns Future<List<SmsMessage>>
Parameters
Type
Description
Optional
Default Value
Columns
Columns to be returned by the query
✔️
[ SmsColumn.ID
, SmsColumn.ADDRESS
, SmsColumn.BODY
, SmsColumn.DATE
]
Filter
Filters the result by given constraints. Works like SQL WHERE
clause.
✔️
null
sortOrder
Sorts the result prioritized by order of declaration.
✔️
null
All parameters are optional.
getSentSms()
Returns Future<List<SmsMessage>>
Parameters
Type
Description
Optional
Default Value
Columns
Columns to be returned by the query
✔️
[ SmsColumn.ID
, SmsColumn.ADDRESS
, SmsColumn.BODY
, SmsColumn.DATE
]
Filter
Filters the result by given constraints. Works like SQL WHERE
clause.
✔️
null
sortOrder
Sorts the result prioritized by order of declaration.
✔️
null
All parameters are optional.
getDraftSms()
Returns Future<List<SmsMessage>>
Parameters
Type
Description
Optional
Default Value
Columns
Columns to be returned by the query
✔️
[ SmsColumn.ID
, SmsColumn.ADDRESS
, SmsColumn.BODY
, SmsColumn.DATE
]
Filter
Filters the result by given constraints. Works like SQL WHERE
clause.
✔️
null
sortOrder
Sorts the result prioritized by order of declaration.
✔️
null
All parameters are optional.
SmsMessage
Property
Type
id
int
address
String
body
String
date
int
in milliseconds
dateSent
int
in milliseconds
read
bool
seen
bool
subject
String
subscriptionId
int
threadId
int
type
SmsType
status
SmsStatus
SmsColumn
Columns
ID
ADDRESS
BODY
DATE
DATE_SENT
READ
SEEN
STATUS
SUBJECT
SUBSCRIPTION_ID
THREAD_ID
TYPE
SmsFilter
Generates a filter that will be used by an query. The methods read like an SQL query. The select part is determined columns
parameter on one of the query methods. The SmsFilter
handle the WHERE
part.
Example
Becomes
Initializing a filter
Sms Filter works like a SQL WHERE
clause. Initialize the filter by calling the where
method and pass in the column name.
Methods
equals()
Compares equality between the column values and the value provided to the function.
greaterThan()
Adds a greater than >
operator.
lessThan()
Adds a less than operator.
greaterThanOrEqualTo()
Adds a greater than or equal to operator.
lessThanOrEqualTo()
Adds a less than or equal to operator.
notEqualTo()
Checks for inequality.
like()
Adds the LIKE
operator.
inValues()
Adds the IN
operator.
between()
Adds the BETWEEN
operator.
not
Adds a NOT
operator.
Combining Methods
and()
Adds the AND
operator between two statements.
or()
Adds the OR
operator between two statements.
OrderBy
Creates an ORDER BY
statement.
Optionally you can provide a sort order. Defaults to DESC
Sort
Values
ASC
DESC
Last updated