本文整理汇总了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);
}