2

For some reason, If I query the CallLog Content provider, I get maximum 500 results. Also, it seems I only get results up to 1 month ago (when my devices Phone app shows me about 8 months at the moment).

I googled it, but all I found was 'Store 'CallLog.Calls' into another table' which offers no solution.

This is my code:

String[] strFields = {
                    android.provider.CallLog.Calls.NUMBER,
                    android.provider.CallLog.Calls.DURATION,
                    android.provider.CallLog.Calls.DATE,
            };

            Cursor cursor = MainApplication.getAppContext().getContentResolver().query(
                    android.provider.CallLog.Calls.CONTENT_URI,
                    strFields,
                    null,
                    null,
                    null
            );

            if (cursor != null) {
                Log.d("aaa", cursor.getCount());
                ...
            }
            ...

I tried adding a higher limit, but nothing changed.

Does anyone know why my results are limited?

Edit:

After digging a little in Android code, I got to a method called removeExpiredEntries() in android.provider.CallLog

private static void removeExpiredEntries(Context context) {
        final ContentResolver resolver = context.getContentResolver();
        resolver.delete(CONTENT_URI, "_id IN " +
                "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
                + " LIMIT -1 OFFSET 500)", null);
}

Which is called every time a call is added to the log :/ This means the call log content provider can return up to 500 entries.

This leaves me with the question: how does the native phone app (in my case, Samsung's phone app) shows what seems to be thousands entries more?

Community
  • 1
  • 1
dors
  • 5,802
  • 8
  • 45
  • 71

1 Answers1

2

So from looking at the logs, I came to the conclusion that the content provider indeed deletes entries when having more than 500, and what the device's Phone app does is save logs by it self

dors
  • 5,802
  • 8
  • 45
  • 71