Skip to content Skip to sidebar Skip to footer

How To Get Last Opened Date Of An Application In Android?

I want to get other applications last opened and used date in an android application... Can anybody help on this?

Solution 1:

save the date every time you open your application into SharedPreferance but before saving it, just read the previous saved date, so now you save each time the user opens the app.

Solution 2:

Just save the last opened date if you want time then date and time both. use SharedPreference to store. The date and time will be stored in milliseconds. Then when you open your application you can retrieve that. Other alternative is to use SQLite Database. Store the last opened date in database. By single row you can work here by upgrading the database everytime you open the application.

It will work like blow example.

@OverridepublicvoidonResume() {
Editore= PreferenceManager.getDefaultSharedPreferences(this).edit();
e.putString("last_activity", getClass().getSimpleName());
e.commit();

super.onResume();
}

Post a Comment for "How To Get Last Opened Date Of An Application In Android?"