Code example for File

Methods: exists, open

0
  } 
   
  @Override 
  public ParcelFileDescriptor openFile(Uri uri, String mode)
    throws FileNotFoundException { 
    File f=new File(getContext().getFilesDir(), uri.getPath());
     
    if (f.exists()) {
      return(ParcelFileDescriptor.open(f,
                                        ParcelFileDescriptor.MODE_READ_ONLY));
    } 
 
    throw new FileNotFoundException(uri.getPath());  
  } 
   
  @Override 
  public Cursor query(Uri url, String[] projection, String selection,
                        String[] selectionArgs, String sort) {
    throw new RuntimeException("Operation not supported");
  }