Android examples for android.net:Uri
is Uri Valid via ParcelFileDescriptor
import java.io.IOException; import android.content.ContentResolver; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.util.Log; public class Main { private static final String TAG = "Util"; public static boolean isUriValid(Uri uri, ContentResolver resolver) { if (uri == null) return false; try {/*from w ww .j a v a 2 s. c o m*/ ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r"); if (pfd == null) { return false; } pfd.close(); } catch (IOException ex) { return false; } return true; } }