Here you can find the source of isExisting(Context context, Uri uri, String selection, String[] args)
Parameter | Description |
---|---|
context | of the application. |
uri | of the content location. |
selection | of the data. |
args | of the selection. |
public static boolean isExisting(Context context, Uri uri, String selection, String[] args)
//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(); } } }