Clear database cache on import

This commit is contained in:
M66B 2017-03-26 16:43:26 +02:00
parent dd4fd5378f
commit a7e8147943
2 changed files with 10 additions and 2 deletions

View File

@ -1277,6 +1277,8 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
// Upgrade imported settings
Receiver.upgrade(true, this);
DatabaseHelper.clearCache();
// Refresh UI
prefs.edit().putBoolean("imported", true).apply();
prefs.registerOnSharedPreferenceChangeListener(this);

View File

@ -55,6 +55,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static HandlerThread hthread = null;
private static Handler handler = null;
private static Map<Integer, Long> mapUidHosts = new HashMap<>();
private final static int MSG_LOG = 1;
private final static int MSG_ACCESS = 2;
private final static int MSG_FORWARD = 3;
@ -81,6 +83,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
return dh;
}
public static void clearCache() {
synchronized (mapUidHosts) {
mapUidHosts.clear();
}
}
@Override
public void close() {
Log.w(TAG, "Database is being closed");
@ -728,8 +736,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
}
private static Map<Integer, Long> mapUidHosts = new HashMap<>();
public long getHostCount(int uid, boolean usecache) {
if (usecache)
synchronized (mapUidHosts) {