android.app.Application#getFilesDir ( )源码实例Demo

下面列出了android.app.Application#getFilesDir ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MetroExample   文件: JsLoaderUtil.java
private static String getReactDir(Application application){
    return application.getFilesDir()+ File.separator+jsState.reactDir+File.separator;
}
 
源代码2 项目: atlas   文件: KernalBundle.java
public static boolean checkLoadKernalDebugPatch(Application application) {
    if (Build.VERSION.SDK_INT < 21) {
        //暂时只支持art设备的debug调试
        return false;
    }

    boolean loadKernalPatch = false;
    try {
        ApplicationInfo app_info = application.getApplicationInfo();
        boolean debug = (app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        if (debug) {
            File debugBundleDir = new File(KernalConstants.baseContext.getExternalFilesDir("debug_storage"), KERNAL_BUNDLE_NAME);
            File patchFile = new File(debugBundleDir, "patch.zip");
            if (patchFile.exists()) {
                loadKernalPatch = true;
                KernalBundle bundle = new KernalBundle();
                //DexFile dexFile = (DexFile) KernalConstants.dexBooster.loadDex(KernalConstants.baseContext, KernalConstants.baseContext.getApplicationInfo().sourceDir,
                //        new File(patchFile.getParent(), "base.dex").getAbsolutePath(), 0, true);

                File internalDebugBundleDir = new File(new File(application.getFilesDir(), "debug_storage"), KERNAL_BUNDLE_NAME);
                internalDebugBundleDir.mkdirs();
                DexFile patchDexFile = (DexFile) DexFile.loadDex(patchFile.getAbsolutePath(),new File(internalDebugBundleDir, "patch.dex").getAbsolutePath(), 0);
                if (bundle.needReplaceClassLoader(application)) {
                    NClassLoader loader = new NClassLoader(".", KernalBundle.class.getClassLoader().getParent());
                    try {
                        NClassLoader.replacePathClassLoader(KernalConstants.baseContext, KernalBundle.class.getClassLoader(), loader);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                bundle.installKernalBundle(KernalConstants.baseContext.getClassLoader(), patchFile, new DexFile[]{patchDexFile/*, dexFile*/}, null,
                    true /*(app_info.flags & ApplicationInfo.FLAG_VM_SAFE_MODE) != 0*/);
                bundle.prepareRuntimeVariables(application);
                Class DelegateResourcesClazz = application.getClassLoader().loadClass("android.taobao.atlas.runtime.DelegateResources");
                DelegateResourcesClazz.getDeclaredMethod("addApkpatchResources", String.class)
                        .invoke(DelegateResourcesClazz, patchFile.getAbsolutePath());
                Toast.makeText(KernalConstants.baseContext, "当前处于DEBUG调试状态,不支持动态更新,清除数据可恢复", Toast.LENGTH_LONG).show();
            }
        }
    } finally {
        return loadKernalPatch;
    }
}
 
源代码3 项目: Xndroid   文件: BookmarkPage.java
@NonNull
public static File getBookmarkPage(@NonNull Application application, @Nullable String folder) {
    String prefix = !TextUtils.isEmpty(folder) ? folder + '-' : "";
    return new File(application.getFilesDir(), prefix + FILENAME);
}
 
源代码4 项目: Xndroid   文件: StartPage.java
@NonNull
public static File getStartPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
源代码5 项目: Xndroid   文件: DownloadsPage.java
@NonNull
private static File getDownloadsPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
源代码6 项目: JumpGo   文件: BookmarkPage.java
@NonNull
public static File getBookmarkPage(@NonNull Application application, @Nullable String folder) {
    String prefix = !TextUtils.isEmpty(folder) ? folder + '-' : "";
    return new File(application.getFilesDir(), prefix + FILENAME);
}
 
源代码7 项目: JumpGo   文件: StartPage.java
@NonNull
public static File getStartPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
源代码8 项目: JumpGo   文件: DownloadsPage.java
@NonNull
private static File getDownloadsPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
源代码9 项目: Xndroid   文件: FileUtils.java
/**
 * Use this method to delete the bundle with the specified name.
 * This is a blocking call and should be used within a worker
 * thread unless immediate deletion is necessary.
 *
 * @param app  the application object needed to get the file.
 * @param name the name of the file.
 */
public static void deleteBundleInStorage(final @NonNull Application app, final @NonNull String name) {
    File outputFile = new File(app.getFilesDir(), name);
    if (outputFile.exists()) {
        outputFile.delete();
    }
}
 
源代码10 项目: JumpGo   文件: FileUtils.java
/**
 * Use this method to delete the bundle with the specified name.
 * This is a blocking call and should be used within a worker
 * thread unless immediate deletion is necessary.
 *
 * @param app  the application object needed to get the file.
 * @param name the name of the file.
 */
public static void deleteBundleInStorage(final @NonNull Application app, final @NonNull String name) {
    File outputFile = new File(app.getFilesDir(), name);
    if (outputFile.exists()) {
        outputFile.delete();
    }
}
 
源代码11 项目: Xndroid   文件: HistoryPage.java
/**
 * Get the file that the history page is stored in
 * or should be stored in.
 *
 * @param application the application used to access the file.
 * @return a valid file object, note that the file might not exist.
 */
@NonNull
private static File getHistoryPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
源代码12 项目: JumpGo   文件: HistoryPage.java
/**
 * Get the file that the history page is stored in
 * or should be stored in.
 *
 * @param application the application used to access the file.
 * @return a valid file object, note that the file might not exist.
 */
@NonNull
private static File getHistoryPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}