本文整理了Java中android.app.Application.getDatabasePath()
方法的一些代码示例,展示了Application.getDatabasePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getDatabasePath()
方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:getDatabasePath
暂无
代码示例来源:origin: roomanl/AndroidDownload
@Override
public File getDatabasePath(String name) {
return app.getDatabasePath(name);
}
代码示例来源:origin: andstatus/andstatus
@Override
public File getDatabasePath(String name) {
return isAcraProcess ? super.getDatabasePath(name) : MyStorage.getDatabasePath(name);
}
代码示例来源:origin: XiqingLiu/JesStatistics
private static void initDB(Application app) {
try {
SharedPreferences spf = app.getSharedPreferences(Constant.SPF_NAME, Context.MODE_PRIVATE);
int old_versionCode = spf.getInt("old_versionCode", -1);
PackageInfo packageInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
if (packageInfo.versionCode > old_versionCode || BuildConfig.DEBUG) {
File path = app.getDatabasePath(Constant.DB_NAME);
if (path.exists()) {
path.delete();
app.getDatabasePath(Constant.DB_NAME + "-journal").delete();
}
spf.edit().putInt("old_versionCode", packageInfo.versionCode).apply();
}
// TODO: 2017/9/13 创建数据库
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: commonsguy/cw-androidarch
private void process(boolean isBackup, int pid) throws IOException {
SystemClock.sleep(1000); // wait for things to settle
Process.killProcess(pid);
File dbDir=getApplication().getDatabasePath("foo").getParentFile();
File extDir=getApplication().getExternalFilesDir(null);
File backupDir=new File(extDir, "db-backup");
if (isBackup) {
if (backupDir.exists()) {
delete(backupDir);
}
backupDir.mkdirs();
copy(dbDir, backupDir);
}
else {
if (dbDir.exists()) {
delete(dbDir);
}
dbDir.mkdirs();
copy(backupDir, dbDir);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!