0

I am building a DashClock extension in which i need to store some values in SharedPrefs just before the device shuts down.

So, does the DashClock widget calls onUpdateData() method before device shuts down? Or, whether it calls onDestroy()?

Or else, should i listen for ACTION_SHUTDOWN broadcast?

Amit Jayant
  • 2,501
  • 2
  • 29
  • 38
  • 1
    No, it doesn't, since there's no general reason to update visible data just before shutdown. Why not store values when you observe a change? That way, they get persisted even during a hard exit. – Roman Nurik Apr 23 '13 at 15:00
  • Thanks for the reply Roman. Actually, i am building a "network data usage" extension. In that i am using the TrafficStats class to get the values. Since the values from TrafficStats class resets to 0 after a reboot, i would like to store the previous values so as to correctly display values on boot. – Amit Jayant Apr 23 '13 at 15:17
  • Ah, understood. In that case I suppose you should set up a separate receiver for `ACTION_SHUTDOWN`. Good luck! – Roman Nurik Apr 23 '13 at 15:26
  • OK, so i will set up a ACTION_SHUTDOWN receiver. Thanks a lot for your reply and for the wonderful DashClock widget :) – Amit Jayant Apr 23 '13 at 15:40

0 Answers0