Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.ContentResolver;

import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog;

public class Main {
    private static final String logOrder = android.provider.CallLog.Calls.DATE + " DESC";
    private static final String contentUri = "content://call_log/calls";
    private static final String[] projection = { CallLog.Calls.CACHED_NAME, CallLog.Calls.NUMBER,
            CallLog.Calls.TYPE, CallLog.Calls.DURATION, CallLog.Calls.DATE, CallLog.Calls.CACHED_PHOTO_ID, };

    public static Cursor getCallLogsByName(ContentResolver cr, String name) {
        String select = android.provider.CallLog.Calls.CACHED_NAME + "=?";
        String[] args = { name };

        return execute(cr, select, args);
    }

    public static Cursor execute(ContentResolver cr, String select, String[] args) {
        return execute(cr, select, args, projection);
    }

    public static Cursor execute(ContentResolver cr, String select, String[] args, String[] _projection) {
        Uri callUri = Uri.parse(contentUri);
        if (_projection == null) {
            _projection = projection;
        }

        return cr.query(callUri, _projection, select, args, logOrder);
    }
}