Android Context Check isExisting(Context context, Uri uri, String selection, String[] args)

Here you can find the source of isExisting(Context context, Uri uri, String selection, String[] args)

Description

Determine whether or not a give URI has an item matching the specified selected and arguments.

License

Apache License

Parameter

Parameter Description
context of the application.
uri of the content location.
selection of the data.
args of the selection.

Return

whether the defined selection with args are found on the URI.

Declaration

public static boolean isExisting(Context context, Uri uri,
        String selection, String[] args) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

public class Main {
    /**/*from  w ww.java2  s  .  co  m*/
     * Determine whether or not a give URI has an item matching the specified selected and
     * arguments.
     *
     * @param context of the application.
     * @param uri of the content location.
     * @param selection of the data.
     * @param args of the selection.
     * @return whether the defined selection with args are found on the URI.
     */
    public static boolean isExisting(Context context, Uri uri,
            String selection, String[] args) {
        Cursor cursor = null;
        try {
            cursor = context.getContentResolver().query(uri, null,
                    selection, args, null);
            return cursor.getCount() > 0;
        } finally {
            if (cursor != null)
                cursor.close();
        }
    }
}

Related

  1. isCallable(Context context, String url)
  2. isConnected(Context connext)
  3. isConnected(Context context)
  4. isDebugCertificateCheck(final Context context)
  5. isDebuggable(final Context context, final boolean includeDefaultDebugCertificateCheck)
  6. isFileExist(Context ctx, String filename)
  7. isFree(Context context)
  8. isGPRSAvailable(Context context)
  9. isGoogleAccountPresent(Context ctx)