Created
April 7, 2015 11:08
-
-
Save beshkenadze/9bb059fba7a0fd8c6a28 to your computer and use it in GitHub Desktop.
Example for get history calls.
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
String[] projection = new String[]{ | |
CallLog.Calls._ID, | |
CallLog.Calls.DATE, | |
CallLog.Calls.NUMBER, | |
CallLog.Calls.CACHED_NAME, | |
CallLog.Calls.DURATION, | |
CallLog.Calls.TYPE | |
}; | |
String where = ""; | |
Cursor cursor = context.getContentResolver().query( | |
CallLog.Calls.CONTENT_URI, | |
projection, | |
where, | |
null, | |
null | |
); | |
if (cursor.moveToFirst()) { | |
do { | |
long _id = cursor.getLong(cursor.getColumnIndex(CallLog.Calls._ID)); | |
String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)); | |
long date = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE)); | |
} while (cursor.moveToNext()); | |
} | |
if (!cursor.isClosed()) { | |
cursor.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment