Code example for Uri

Methods: getPath, getScheme

0
  } 
 
  @Implementation 
  public final InputStream openInputStream(final Uri uri) {
 
    if (uri != null && ContentResolver.SCHEME_ANDROID_RESOURCE.equals(uri.getScheme())) {
      String path = uri.getPath();
      // check that path is a numerical resource id 
      if (path != null && path.matches("/[0-9]+")) {
        int resourceId = Integer.parseInt(path.substring(1));
        return Robolectric.application.getResources().openRawResource(resourceId);
      } 
    } 
 
    return new MyInputStream(uri);
  } 
 
  @Implementation 
  public final OutputStream openOutputStream(final Uri uri) {
    return new OutputStream() {