How to lock levels in Android app -


i developing quiz application in android. in application i'm having categories , added levels in each category. need lock categories except first one. user able unlock categories after he/she completes specific goal of level. don't know how lock categories in android. categories in form of buttons. using following i'm populating list , passing of 3 categories, i.e. hollywood, bollywood , music.

hollywood = (button) findviewbyid(r.id.main_hollywood);     typeface tf = typeface.createfromasset(getcontext().getassets(),             "font/game_font.ttf");     hollywood.settypeface(tf);     onclicklistener listener = new onclicklistener() {          @override         public void onclick(view v) {             settings.edit().putboolean("check", false).commit();             intent intent = new intent(getcontext(), sceneactivity.class);             intent.setflags(intent.flag_activity_clear_top);              startactivity(intent);             finish();         }     };     hollywood.setonclicklistener(listener);       bollywood = (button) findviewbyid(r.id.main_bollywood);     tf = typeface.createfromasset(getcontext().getassets(),             "font/game_font.ttf");     bollywood.settypeface(tf);     listener = new onclicklistener() {          @override         public void onclick(view v) {             settings.edit().putboolean("check", false).commit();             intent intent = new intent(getcontext(), sceneactivity1.class);             intent.setflags(intent.flag_activity_clear_top);              startactivity(intent);             finish();         }     };     bollywood.setonclicklistener(listener);     music = (button) findviewbyid(r.id.main_music);     tf = typeface.createfromasset(getcontext().getassets(),             "font/game_font.ttf");     music.settypeface(tf);     listener = new onclicklistener() {          @override         public void onclick(view v) {             settings.edit().putboolean("check", false).commit();             intent intent = new intent(getcontext(), sceneactivity2.class);             intent.setflags(intent.flag_activity_clear_top);              startactivity(intent);             finish();         }     };     music.setonclicklistener(listener);   } 

there 2 methods solve this

  1. use shared preference in application can handle situation onlick

  2. use sqlite database , update column appropriately

let me know if need further information

for shared preference can use tinydb

this class simplifies calls sharedpreferences in line of code. can more like: saving list of strings, integers , saving images. in 1 line of code!

example usage:

    tinydb tinydb = new tinydb(context);      tinydb.putint("clickcount", 2);     tinydb.putfloat("xpoint", 3.6f);      tinydb.putlong("usercount", 39832l);      tinydb.putstring("username", "john");     tinydb.putboolean("isusermale", true);       tinydb.putlist("myusers", musersarray);     tinydb.putimagepng("dropbox/workimages", "meatlunch.png", lunchbitmap); 

//these plus corresponding methods included example of how easy use. there many more usefull methods included in class. enjoy :)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -