当前位置: 首页>>代码示例>>Java>>正文


Java Application.getFilesDir方法代码示例

本文整理汇总了Java中android.app.Application.getFilesDir方法的典型用法代码示例。如果您正苦于以下问题:Java Application.getFilesDir方法的具体用法?Java Application.getFilesDir怎么用?Java Application.getFilesDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Application的用法示例。


在下文中一共展示了Application.getFilesDir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBenchFile

import android.app.Application; //导入方法依赖的package包/类
private File getBenchFile(String name) {
    File dir = Environment.getExternalStorageDirectory();
    File file = new File(dir, name);
    if (dir == null || !dir.canWrite()) {
        Application app = createApplication(Application.class);
        File appFile = new File(app.getFilesDir(), name);
        DaoLog.d("Using file " + appFile.getAbsolutePath() + ", (cannot write to " + file.getAbsolutePath() + ")");
        file = appFile;
    }
    return file;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:PerformanceTest.java

示例2: checkLoadKernalDebugPatch

import android.app.Application; //导入方法依赖的package包/类
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)KernalConstants.dexBooster.loadDex(KernalConstants.baseContext,patchFile.getAbsolutePath(),
                        new File(internalDebugBundleDir,"patch.dex").getAbsolutePath(),0,true) ;
                bundle.installKernalBundle(KernalConstants.baseContext.getClassLoader(), patchFile, new DexFile[]{patchDexFile,dexFile}, null,
                                           true /*(app_info.flags & ApplicationInfo.FLAG_VM_SAFE_MODE) != 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.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;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:45,代码来源:KernalBundle.java

示例3: getBookmarkPage

import android.app.Application; //导入方法依赖的package包/类
@NonNull
public static File getBookmarkPage(@NonNull Application application, @Nullable String folder) {
    String prefix = !TextUtils.isEmpty(folder) ? folder + '-' : "";
    return new File(application.getFilesDir(), prefix + FILENAME);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:6,代码来源:BookmarkPage.java

示例4: getStartPageFile

import android.app.Application; //导入方法依赖的package包/类
@NonNull
public static File getStartPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:5,代码来源:StartPage.java

示例5: getDownloadsPageFile

import android.app.Application; //导入方法依赖的package包/类
@NonNull
private static File getDownloadsPageFile(@NonNull Application application) {
    return new File(application.getFilesDir(), FILENAME);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:5,代码来源:DownloadsPage.java

示例6: deleteBundleInStorage

import android.app.Application; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:15,代码来源:FileUtils.java

示例7: getHistoryPageFile

import android.app.Application; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:12,代码来源:HistoryPage.java


注:本文中的android.app.Application.getFilesDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。