views:

41

answers:

3

How can I store data in a mobile widget (JIL/W3C). Is Widget.setPreferenceForKey() the only option?

+1  A: 

You can store small-size data using Widget.setPreferenceForKey() method and retrieve it with Widget.preferenceForKey(). There are no other options at this moment.

Radu Cojocaru
+2  A: 

Not really different to Radu's solution, but it allows you to store data in a persistent way. So your widget can store data on many different devices and in the browser.

You can read about it here: http://tinyhippos.com/2010/04/11/mobile-widgets-persistence-cross-platform-wrapper/

Hope it helps.

Tosa
+1  A: 

Yes, what Radu sais, it's the only option, if you want to persist the data. Keep in mind, though, that it's a key/value store and that keys and values are strings. To store objects, you'd need to convert them to/from JSON.

Documentation sadly is rare on this, but this is a good point to start: Opera dev

Jens Arps