Example usage for android.content Context getFilesDir

List of usage examples for android.content Context getFilesDir

Introduction

In this page you can find the example usage for android.content Context getFilesDir.

Prototype

public abstract File getFilesDir();

Source Link

Document

Returns the absolute path to the directory on the filesystem where files created with #openFileOutput are stored.

Usage

From source file:Main.java

public static boolean isFilePresent(String fileName, Context context) {
    String[] files = context.getFilesDir().list();
    for (int i = 0; i < files.length; i++) {
        if (files[i].equals(fileName)) {
            return true;
        }//from   w w w . j a  v  a2s  .c om
    }
    return false;
}

From source file:Main.java

public static File getDataFileSoPatchForInstall(Context base) {
    File dir = new File(base.getFilesDir().getAbsolutePath() + File.separator + "rocoolib" + File.separator);
    if (!dir.exists()) {
        dir.mkdirs();/* ww w .j  a  v  a2 s.c  o  m*/
    }
    return dir;
}

From source file:Main.java

public static Bitmap getIconForAppPath(Context context) {
    String path = context.getFilesDir().getPath() + "/crop.png";
    File file = new File(path);
    if (file.exists()) {
        return BitmapFactory.decodeFile(path);
    }/*from w w  w.j a  v a  2  s.  c om*/
    return null;
}

From source file:Main.java

private static File getInstallationFile(final Context context) {
    return new File(context.getFilesDir(), INSTALLATION);
}

From source file:Main.java

public static void setPreferenceFileWorldReadable(Context context, String preferenceName) {
    new File(context.getFilesDir().getParentFile(), "shared_prefs/" + preferenceName + ".xml").setReadable(true,
            false);//from   w  w w  . j  ava 2 s . c  o  m
}

From source file:Main.java

public static File getApplicationFile(Context context, String fileName) {
    return new File(context.getFilesDir() + File.separator + fileName);
}

From source file:Main.java

public static void clearLoginResult(Context context) {
    File signinFile = new File(context.getFilesDir(), "signin");
    if (signinFile.exists()) {
        signinFile.delete();//from  w  ww . ja va 2 s  .  c om
    }
}

From source file:Main.java

public static File getFilesDir(Context context) {
    File result = context.getFilesDir();
    if (result == null) {
        result = context.getDir("files", 0);
    }/*from ww w. ja  v a 2  s .  com*/
    if (result == null) {
        result = new File("/data/data/" + context.getPackageName() + "/app_files");
    }
    if (!result.exists()) {
        result.mkdirs();
    }
    return result;
}

From source file:Main.java

public static String getAbsolutePathOnInternalStorage(final Context pContext, final String pFilePath) {
    return pContext.getFilesDir().getAbsolutePath() + pFilePath;
}

From source file:Main.java

public static void cleanFiles(Context context) {
    deleteFilesByDirectory(context.getFilesDir());
}