android - How to know the last launch time of an app -


hi after doing lots of search , not find answer of question, seems simple.

i have multiple apps installed on device. there way of finding last launching date of apps?

you put time , date in sharedpref when app opens. then, next time open app app reads sharedpref , displays it.

something this:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      calendar c = calendar.getinstance();      sharedpreferences sp = this.getpreferences(context.mode_private);      string lastlaunch = sp.getstring("launch", "first launch!");      sharedpreferences.editor editor = sp.edit();     editor.putstring("launch", c.gettime().tostring());     editor.commit(); } 

the string lastlaunch last time launched! if it's first time string is: "first launch!"

i hope have helped little bit :)


Comments