Last active
August 3, 2016 10:30
-
-
Save tshirtman/efe110309d4b22f3a97b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_message(cursor): | |
return ( | |
cursor.getString(cursor.getColumnIndex('_id')), | |
cursor.getString(cursor.getColumnIndex('address')), | |
cursor.getString(cursor.getColumnIndex('body'))) | |
def fetch_messages(lastindex): | |
if platform == 'android': | |
uriSms = Uri.parse('content://sms') | |
cursor = context.getContentResolver().query( | |
uriSms, | |
['_id', 'address', 'body', 'type', 'read'], | |
"type=1", None, | |
"date COLLATE LOCALIZED ASC limit 10 offset %s" % lastindex) | |
if cursor and cursor.getCount(): | |
cursor.moveToFirst() | |
yield get_message(cursor) | |
while cursor.moveToNext(): | |
yield get_message(cursor) | |
cursor.close() | |
del(cursor) | |
else: | |
for i in range(10): | |
yield ('%s' % i, 'message%s' % i) |
Author
tshirtman
commented
Aug 3, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment