0

I'm writing an android socket client application that employs a socket connection and I'm having a lot of trouble deciding the best way persist the socket data across different activities.

What I'd like to do is have the initial activity of my client android application send a log-in command through the socket and read the initial configuration of my data out of the socket and into an Object that then becomes available to all of the activities in my application.

After the Object has been initialized it should be updated on a regular basis by sending a command through the socket and reading the socket response into the Object.

The different activities of my application display subsets of the data contained in this Object and occasionally send a command through the socket.

My thinking was to create an android Service that would employ a background thread to poll the socket on a regular basis and store the data in an Object but I think my main problem is how do I persist this data Object without storing it in a SQLite database? It needs to be updated on a regular basis and be accessible by several different activities.

rushinge
  • 1,198
  • 5
  • 15
  • 25
  • create a singleton which extends `Application` and use `(YourSingletonName)context.getApplication()` to retrieve it. store any object in this object that you want to persist across activities. – james Jan 20 '11 at 20:04
  • Check out http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables/708317#708317 – w.donahue Jan 21 '11 at 07:19

0 Answers0