當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。