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.content.Context;
import android.database.Cursor;

import android.net.Uri;

public class Main {
    public static Cursor query(final Context context, final Uri uri, final String[] projection,
            final String selection, final String[] selectionArgs, final String sortOrder) {
        return query(context, uri, projection, selection, selectionArgs, sortOrder, 0);
    }

    public static Cursor query(final Context context, Uri uri, final String[] projection, final String selection,
            final String[] selectionArgs, final String sortOrder, final int limit) {
        try {
            final ContentResolver resolver = context.getContentResolver();
            if (resolver == null) {
                return null;
            }
            if (limit > 0) {
                uri = uri.buildUpon().appendQueryParameter("limit", "" + limit).build();
            }
            return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
        } catch (final UnsupportedOperationException ex) {
            return null;
        }

    }
}