Search in sources :

Example 1 with BulkReportDeleter

use of org.acra.file.BulkReportDeleter in project acra by ACRA.

the class ApplicationStartupProcessor method deleteUnsentReportsFromOldAppVersion.

/**
     * Delete any old unsent reports if this is a newer version of the app than when we last started.
     */
public void deleteUnsentReportsFromOldAppVersion() {
    final SharedPreferences prefs = new SharedPreferencesFactory(context, config).create();
    final long lastVersionNr = prefs.getInt(ACRA.PREF_LAST_VERSION_NR, 0);
    final int appVersion = getAppVersion();
    if (appVersion > lastVersionNr) {
        final BulkReportDeleter reportDeleter = new BulkReportDeleter(context);
        reportDeleter.deleteReports(true, 0);
        reportDeleter.deleteReports(false, 0);
        final SharedPreferences.Editor prefsEditor = prefs.edit();
        prefsEditor.putInt(ACRA.PREF_LAST_VERSION_NR, appVersion);
        PrefUtils.save(prefsEditor);
    }
}
Also used : BulkReportDeleter(org.acra.file.BulkReportDeleter) SharedPreferences(android.content.SharedPreferences) SharedPreferencesFactory(org.acra.prefs.SharedPreferencesFactory)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 BulkReportDeleter (org.acra.file.BulkReportDeleter)1 SharedPreferencesFactory (org.acra.prefs.SharedPreferencesFactory)1