List of usage examples for android.content Context getFileStreamPath
public abstract File getFileStreamPath(String name);
From source file:Main.java
private static boolean isExistDataCache(Context context, String cachefile) { boolean exist = false; File data = context.getFileStreamPath(cachefile); if (data.exists()) exist = true;//from w ww. j a v a2 s . co m return exist; }
From source file:Main.java
public static String readFile(Context context, String name) throws IOException { File file = context.getFileStreamPath(name); InputStream is = new FileInputStream(file); byte b[] = new byte[(int) file.length()]; is.read(b);/*from w w w. j ava 2 s. co m*/ is.close(); String string = new String(b); return string; }
From source file:Main.java
/** * Calculates the size of the given file located in internal storage. * * @author Ian Copland// w ww. j a v a 2 s . com * * @param in_context - The active context. * @param in_filePath - The path to the file which is to have its size calculated. * * @return The size of the file in bytes. */ public static long getFileSize(Context in_context, String in_filePath) { File file = in_context.getFileStreamPath(in_filePath); return file.length(); }
From source file:Main.java
/** * @author Ian Copland//from w ww . j a v a 2 s . c o m * * @param in_context - The current context. * @param in_filePath - The file path. * * @return Whether or not the given file exists in internal storage. */ public static boolean doesFileExist(Context in_context, String in_filePath) { File file = in_context.getFileStreamPath(in_filePath); if (file.exists() == true && file.isFile() == true) { return true; } return false; }
From source file:Main.java
/** * Rename existing file in same directory if target file exists, delete * Code nicked from http://stackoverflow.com/users/325442/mr-bungle * @param context/*from www . java 2 s . com*/ * @param originalFileName * @param newFileName */ private static void rename(Context context, String originalFileName, String newFileName) { File originalFile = context.getFileStreamPath(originalFileName); if (originalFile.exists()) { Log.d("SavingHelper", "renaming " + originalFileName + " size " + originalFile.length() + " to " + newFileName); File newFile = new File(originalFile.getParent(), newFileName); if (newFile.exists()) { context.deleteFile(newFileName); } originalFile.renameTo(newFile); } }
From source file:Main.java
public static void deleteTempPackageFile(Context context, String pathOnSDCard) { File file = new File(pathOnSDCard); File tmpPackageFile = context.getFileStreamPath(file.getName()); if (tmpPackageFile == null) { return;//from ww w .ja v a 2s . co m } if (tmpPackageFile.exists()) { tmpPackageFile.delete(); } }
From source file:Main.java
static boolean isQuantified(Context appContext) { File quantified = appContext.getFileStreamPath(QCMEASUREMENT_OPTOUT_STRING); return quantified != null && quantified.exists(); }
From source file:Main.java
public static boolean installDll(Context context) { boolean isSuccess = false; File file = context.getFileStreamPath("Disdll.dll"); boolean isDeleteSuccess = true; if (file.exists()) { isDeleteSuccess = file.delete(); }//from w w w . j a v a 2 s .c om if (isDeleteSuccess) { try { FileOutputStream outputStream = context.openFileOutput("Disdll.dll", Context.MODE_PRIVATE); InputStream inputStream = context.getAssets().open("Disdll.dll"); byte[] temp = new byte[1024]; int len = -1; while ((len = inputStream.read(temp)) != -1) { outputStream.write(temp, 0, len); } outputStream.flush(); outputStream.close(); inputStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } isSuccess = checkIfDllInstalled(context); } return isSuccess; }
From source file:Main.java
public static boolean isExistDataCache(Context context, String cachefile) { if (context == null) return false; boolean exist = false; File data = context.getFileStreamPath(cachefile); if (data.exists()) exist = true;/*from ww w. j a v a 2 s .c om*/ return exist; }
From source file:Main.java
private static boolean isExistDataCache(Context context, String cacheFile) { if (context == null || TextUtils.isEmpty(cacheFile)) { return false; }/*from w ww. ja va2 s . c om*/ boolean exist = false; File data = context.getFileStreamPath(cacheFile); if (data.exists()) exist = true; return exist; }