Yes, I didn't think about that! That could definitely help me! But in this case:
1 - What would be the life cycle of this class singleton if the user sends the application (and so the activity that was displayed) in the background and the activity is destroyed for instance? 2 - How to make sure this singleton will stay alive as long as the secondary thread needs? 3 - I still don't really understand what happens when the secondary thread posts runnable toward the UI main thread that has been destroyed or sent to the background! Thanks a lot for your answer, It really helps me! Polo On Jan 21, 4:16 pm, Dianne Hackborn <[email protected]> wrote: > I would recommend having a singleton that all of the clients go through, > which takes care of keeping the database open as long as there are clients > of it. > > > > On Wed, Jan 21, 2009 at 2:45 PM, polo777 <[email protected]> wrote: > > > Hi everyone, > > > I have two threads: > > - the main one in charge of the UI > > - a second one that takes care of network calls, parsing responses and > > database updates. > > > The main threads open the database, retrieves information into a > > Cursor that is used to feed a listView. > > > My problem is the following: When I close the application the activity > > is destroyed, the second thread can still be running and thereby still > > can update the DB. Since the main thread open the DB, I want to close > > it to do the stuffs properly. > > > However if I close it within the onDestroy method and if the second > > thread is running and is about to update the DB, I get an error. > > > What is the best way to handle this situation? > > > Thanks a lot > > Polo > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support. All such questions should be posted on public > forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

