Android Studio save settings of custom SQLite filter (make new database?) -


i have database , created custom filter in dialogue allow me searching database.

basically, sends string want filter mainactivity via interface. working.

my question is: want save filter, when activity/app restarts, last selected filter still selected.

how achieve this? should make new database save state of filter? seems method can think of right now, wonder whether can save state of filter in way?

below filterdialog class, if necessary.

public class filterdialog {  spinner spinner; checkbox cb; onmyfilterresult mfilterresult; string selectedcategory;  public void showdialog(final activity activity) {      final alertdialog.builder builder = new alertdialog.builder(activity);     builder.settitle("filter");     builder.setview(r.layout.dialog_filter);      builder.setpositivebutton("save", new dialoginterface.onclicklistener() {         @override         public void onclick(dialoginterface dialog, int which) {             if (cb.ischecked()) {                 selectedcategory = handcategoryspinner.getselecteditem().tostring();              } else {                 selectedcategory = null;              }              mfilterresult.finish(selectedcategory);          }     });      builder.setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() {         @override         public void onclick(dialoginterface dialog, int which) {              dialog.cancel();         }     });      alertdialog dialog = builder.create();     dialog.show();      spinner = (spinner) dialog.findviewbyid(r.id.spinner);     arrayadapter ad = arrayadapter.createfromresource(activity, r.array.category, android.r.layout.simple_spinner_dropdown_item);     spinner.setadapter(ad);      cb = (checkbox) dialog.findviewbyid(r.id.cb);  }  public void setfilterresult(onmyfilterresult filterresult){     mfilterresult = filterresult; }  public interface onmyfilterresult{     void finish(string result); } } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -