I'm trying to implement a time counter (counts up from 0) which basically gets the saved time variable (startTime, which was created as soon as the user tapped a button) and subtracts the current time (Calendar.getInstance() maybe?) so that the result is the difference (in HH:MM:SS) between the two times. This method will be run on every tick of a chronometer so that the text view will be updated every second, effectively creating my timer.
Now, I take this roundabout route because it's the only way I could figure out to conserve the elapsed time even if the app is killed. This is because the startTime variable gets saved to the SharedPreferences as soon as it's created, and during each Tick, the system calculates my timer on the spot by just finding the difference between the startTime and current time.
now, I've tried making my startTime a Calendar variable and initialised as such:
Calendar startTime = Calendar.getInstance();
and then
elapsedTime = startTime - Calendar.getInstance();
But evidently, this doesn't work.
In a similar project, written in C#, I was able to get this to work, albeit using a DateTime variable... Is there any such way in Android?
If this is just way too convoluted, is there a better way to conserve my chronometer progress?
Please and thank you!