I want to get other applications last opened and used date in an android application...
Can anybody help on this?
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.
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.
@Override
public void onResume() {
Editor e = PreferenceManager.getDefaultSharedPreferences(this).edit();
e.putString("last_activity", getClass().getSimpleName());
e.commit();
super.onResume();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With