Code example for File

Methods: canWrite, exists

0
 
    // TODO: Super gnarly (copied from SaveCopyTask.java), do cleanup. 
 
    public static File getFinalSaveDirectory(Context context, Uri sourceUri) {
        File saveDirectory = getSaveDirectory(context, sourceUri);
        if ((saveDirectory == null) || !saveDirectory.canWrite()) {
            saveDirectory = new File(Environment.getExternalStorageDirectory(),
                    DEFAULT_SAVE_DIRECTORY);
        } 
        // Create the directory if it doesn't exist 
        if (!saveDirectory.exists())
            saveDirectory.mkdirs();
        return saveDirectory;
    } 
 
 
 
    public static String getNewFileName(long time) {
        return new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time));
    }