[2.13.2][fix]解决数据库崩溃的问题
This commit is contained in:
@@ -105,23 +105,27 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date currDate = new Date(System.currentTimeMillis());
|
||||
String currTimeStr = format.format(currDate);
|
||||
if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) {
|
||||
boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr);
|
||||
// 超过一天需要清除消息盒子中的数据,并把时间戳存入SP
|
||||
if (!isSameDay) {
|
||||
try {
|
||||
if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) {
|
||||
boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr);
|
||||
// 超过一天需要清除消息盒子中的数据,并把时间戳存入SP
|
||||
if (!isSameDay) {
|
||||
File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
if (file != null && file.exists()) {
|
||||
this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
SPUtils.getInstance().put("last_launch", currTimeStr);
|
||||
}
|
||||
} else {
|
||||
// 首次使用App或中途仅删除sp文件
|
||||
File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
if (file != null && file.exists()) {
|
||||
this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
SPUtils.getInstance().put("last_launch", currTimeStr);
|
||||
}
|
||||
} else {
|
||||
// 首次使用App或中途仅删除sp文件
|
||||
File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
if (file != null && file.exists()) {
|
||||
this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
SPUtils.getInstance().put("last_launch", currTimeStr);
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, e.getMessage());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@@ -129,11 +133,18 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
private void checkMonitorDb() {
|
||||
new Thread(() -> {
|
||||
long limitId = 50001;
|
||||
List<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
|
||||
List<MemInfo> memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId);
|
||||
// 大于5w条清除
|
||||
if (cpuList.size() > 0 || memList.size() > 0) {
|
||||
this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME);
|
||||
File file = this.getDatabasePath(MonitorDb.INTERNAL_DB_NAME);
|
||||
try {
|
||||
if (file != null && file.exists()) {
|
||||
List<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
|
||||
List<MemInfo> memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId);
|
||||
// 大于5w条清除
|
||||
if (cpuList.size() > 0 || memList.size() > 0) {
|
||||
this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(TAG, e.getMessage());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user