本文整理匯總了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;
}
示例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;
}
}
示例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);
}
示例4: getStartPageFile
import android.app.Application; //導入方法依賴的package包/類
@NonNull
public static File getStartPageFile(@NonNull Application application) {
return new File(application.getFilesDir(), FILENAME);
}
示例5: getDownloadsPageFile
import android.app.Application; //導入方法依賴的package包/類
@NonNull
private static File getDownloadsPageFile(@NonNull Application application) {
return new File(application.getFilesDir(), FILENAME);
}
示例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();
}
}
示例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);
}