Code example for File

Methods: fromFile

0
        // public pictures directory.  Note that you should be careful about 
        // what you place here, since the user often manages these files.  For 
        // pictures and other media owned by the application, consider 
        // Context.getExternalMediaDir(). 
        File path = getExternalFilesDirEclair(ctx, null);
        File file = new File(path, filename);
 
        // Make sure the Pictures directory exists. 
        path.mkdirs();
 
        // Very simple code to copy a picture from the application's 
        // resource into the external file.  Note that this code does 
        // no error checking, and assumes the picture is small (does not 
        // try to copy it in chunks).  Note that if external storage is 
        // not currently mounted this will silently fail. 
        InputStream is = new ByteArrayInputStream(outdata);
        OutputStream os = new FileOutputStream(file);
        byte[] data = new byte[is.available()];
        is.read(data);
        os.write(data);
        is.close();
        os.close();
 
    	Uri tmpImageUri = Uri.fromFile(file);
    	 
    	return tmpImageUri;
 
       
    }