But what if you need to close the connection and you don't want to put it 
in the onDestroy, coz the onDestroy gets called when you change the 
orientation.

We don't need to keep closing and opening the connection when ever the 
activity gets recreated. Also we need it such a way that the activity needs 
to destroyed on origination change.



What are my options ?

On Friday, June 24, 2011 5:32:02 AM UTC-4, Jay wrote:
>
> Got it, thanks Michael. -Jay
>
> 2011/6/23 Michael Kuethe <de0...@googlemail.com <javascript:>>
>
>> Hi Jay,
>> no you just have to call the closing mechanism once. Normally during
>> the onDestroy() event of last Activity that remains on the system.
>> This is normally the launcher Activity.
>>
>> @Override
>>        protected void onDestroy() {
>>                Log.d(TAG, "onDestroy fired!");
>>                dbhelper.close();
>>                super.onDestroy();
>>        }
>>
>>
>> regards
>>
>> Michael
>>
>>
>> On Jun 21, 11:29 am, Jay XU <jaytraveler...@gmail.com> wrote:
>> > Hi,
>> >
>> > I am new to Android and I am looking at the Notepad Tutorial sample code
>> > now. In the NotesDbAdapter class, it defines a close() method to close 
>> the
>> > DatabaseHelper. However I cannot find this method get called anywhere.
>> >
>> > So my question is when shall we close the DB connection. I suppose we 
>> should
>> > call it in the onDestroy() mehod of each Activity class. Or will Android
>> > framework will take care of this so we don't have to worry about it?
>> >
>> > Please advise. thanks.
>> >
>> > -Jay
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to 
>> android-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to