Ask before resetting DB

This commit is contained in:
AdrianLxM 2016-11-08 22:35:57 +01:00 committed by GitHub
parent d3582dab36
commit 218ccc803b

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps; package info.nightscout.androidaps;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -7,6 +8,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
@ -110,7 +112,17 @@ public class MainActivity extends AppCompatActivity {
startActivity(i); startActivity(i);
break; break;
case R.id.nav_resetdb: case R.id.nav_resetdb:
new AlertDialog.Builder(getApplicationContext())
.setTitle(R.string.nav_resetdb)
.setMessage(R.string.reset_db_confirm)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialog, int which) {
MainApp.getDbHelper().resetDatabases(); MainApp.getDbHelper().resetDatabases();
}
})
.create()
.show();
break; break;
case R.id.nav_export: case R.id.nav_export:
ImportExportPrefs.verifyStoragePermissions(this); ImportExportPrefs.verifyStoragePermissions(this);