Example usage for android.app Activity getExternalFilesDir

List of usage examples for android.app Activity getExternalFilesDir

Introduction

In this page you can find the example usage for android.app Activity getExternalFilesDir.

Prototype

@Override
    public File getExternalFilesDir(String type) 

Source Link

Usage

From source file:Main.java

public static File getExternalFilesDir(Activity activity, String type) {
    return activity.getExternalFilesDir(type);
}

From source file:Main.java

public static File getPhotoDirectory(Activity a) {
    File folder = a.getExternalFilesDir(null);

    if (!folder.exists()) {
        folder.mkdirs();/* w ww.j  a  v  a 2  s .co  m*/
        System.out.println("Making bad_camera folder.");
    }

    return folder;
}

From source file:Main.java

public static void clearTemp(Activity activity) {
    File folder = new File(activity.getExternalFilesDir(null), "temp");
    if (null != folder.listFiles()) {
        for (File file : folder.listFiles()) {
            file.delete();/*  w w  w.  j  a  va2 s .  c om*/
        }
    }
}

From source file:Main.java

public static File getAvatarPath(Activity activity, String avatrType, String fielName) {
    File dir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    //        File dir =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    dir = new File(dir, avatrType);
    if (!dir.exists()) {
        dir.mkdirs();/*from  w  ww.  jav  a2 s  .co  m*/
    }
    File file = new File(dir, fielName);
    return file;
}

From source file:Main.java

/**
 * Creates a new File to be used by the picture taken, in the DCIM/bad_camera directory.
 * @param a Actibity used to create file
 * @return A File object where the FileOutputStream can write the .jpeg to.
 *//* w w  w  .  jav a 2  s .  c  om*/
public static File createNewFile(Activity a) {
    //Set a new path file based on the current timestamp.
    //We keep in milliseconds in case we take multiple photos within a one second window.
    Long tsLong = System.currentTimeMillis();
    String file = tsLong.toString() + ".jpg";

    return new File(a.getExternalFilesDir(null), file);

}

From source file:com.nextgis.mobile.fragment.SettingsFragment.java

protected static void resetSettings(Activity activity) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
    SharedPreferences.Editor editor = preferences.edit();
    editor.remove(SettingsConstantsUI.KEY_PREF_THEME);
    editor.remove(SettingsConstantsUI.KEY_PREF_COMPASS_TRUE_NORTH);
    editor.remove(SettingsConstantsUI.KEY_PREF_COMPASS_MAGNETIC);
    editor.remove(SettingsConstantsUI.KEY_PREF_COMPASS_KEEP_SCREEN);
    editor.remove(SettingsConstantsUI.KEY_PREF_COMPASS_VIBRATE);
    editor.remove(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL);
    editor.remove(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC);
    editor.remove(AppSettingsConstants.KEY_PREF_SHOW_COMPASS);
    editor.remove(SettingsConstantsUI.KEY_PREF_KEEPSCREENON);
    editor.remove(SettingsConstantsUI.KEY_PREF_COORD_FORMAT);
    editor.remove(AppSettingsConstants.KEY_PREF_SHOW_ZOOM_CONTROLS);
    editor.remove(SettingsConstantsUI.KEY_PREF_LOCATION_SOURCE);
    editor.remove(SettingsConstantsUI.KEY_PREF_LOCATION_MIN_TIME);
    editor.remove(SettingsConstantsUI.KEY_PREF_LOCATION_MIN_DISTANCE);
    editor.remove(SettingsConstantsUI.KEY_PREF_LOCATION_ACCURATE_COUNT);
    editor.remove(SettingsConstantsUI.KEY_PREF_TRACKS_SOURCE);
    editor.remove(SettingsConstantsUI.KEY_PREF_TRACKS_MIN_TIME);
    editor.remove(SettingsConstantsUI.KEY_PREF_TRACKS_MIN_DISTANCE);
    editor.remove(SettingsConstantsUI.KEY_PREF_TRACK_RESTORE);
    editor.remove(AppSettingsConstants.KEY_PREF_SHOW_MEASURING);
    editor.remove(AppSettingsConstants.KEY_PREF_SHOW_SCALE_RULER);
    editor.remove(SettingsConstantsUI.KEY_PREF_SHOW_GEO_DIALOG);
    editor.remove(AppSettingsConstants.KEY_PREF_GA);

    File defaultPath = activity.getExternalFilesDir(SettingsConstantsUI.KEY_PREF_MAP);
    if (defaultPath == null) {
        defaultPath = new File(activity.getFilesDir(), SettingsConstantsUI.KEY_PREF_MAP);
    }/*from w  w  w  .ja  v a2  s  . co  m*/

    editor.putString(SettingsConstantsUI.KEY_PREF_MAP_PATH, defaultPath.getPath());
    editor.apply();

    PreferenceManager.setDefaultValues(activity, R.xml.preferences_general, true);

    //        moveMap(activity, defaultPath);
}