-2

I have an android application and I want that when I open the app(when a user opens the app) to save the date and time the app was opened in a file. I want this to be done automatically, for each opening. I searched for this and found nothing. Do you have any idea for a code that is able to do this? Please don't tell me to post any code I tried, because I didn't even know where to start. I thought about using Calendar and SharedPreferences..maybe?

Thank you! I would really appreciate your help.

Jason
  • 27
  • 5
  • Start by breaking down your desired outcome into the simple individual steps (lifecycle of the app--get entry point, get date/time, how to save a file on android devices, what permissions do you need...) – Barns Feb 12 '18 at 20:04

1 Answers1

0

Calendar and shared preferences will work. But more elegant solution will be calendar and SQLite database. See Create SQLite database in android. To save date and time everytime you open app, simply put your code in onCreate() method of the main activity.

hyperCoder
  • 271
  • 2
  • 13