>
> The scenario is i have 2 edit text and have entered some data i want to
> retain the data when the activity is killed and started again.



> This can be achieved using onSaveInstanceState() but as documentation says,
> this method is not a lifecycle method and hence the callback is not
> guaranteed.


You've given yourself the answer. Use onSavedInstanceState and
onRestoreInstanceState, that's what they're here for. It's not guaranteed if
you're app is not in danger of being deleted or if it's shutting down for
good. In general though, it will be called when your app is left without
being "finished()" and you return to it, if it had to be destroyed to
reclaim memory.

If you need more persistent storage (like you want those string values to
come back as the last thing the user entered, even if they closed the app
manually) then you need to save the data to a file and restore it in
onCreate()

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Wed, Jan 13, 2010 at 4:22 AM, kavitha sunil <[email protected]>wrote:

> Could you please elaborate or give me the piece of code if you have already
> implemented the same.
> As there is no Bundle argument passed to onPause() method.
>
> I tried using this.getIntent().putExtras(Bundle) in OnPause() and
> retrieving the same in onCreate.
> But the value is null.
> Is this not the right way to do?
>
> On Wed, Jan 13, 2010 at 3:48 PM, Nithin <[email protected]> wrote:
>
>>
>> You can use bundle in onPause(). onPause() will call all the time,
>> whenever the activity lose focus, or when the activity is invisble and
>> can restore in onResume() as well.
>>
>> Nithin
>>
>>
>> On Jan 13, 2:28 pm, Android Developer <[email protected]>
>> wrote:
>>  > Hi,
>> >
>> > Is it possible to use bundle and save the data in OnPause() lifecycle
>> > method?
>> > The scenario is i have 2 edit text and have entered some data
>> > i want to retain the data when the activity is killed and started
>> > again.
>> >
>> > This can be achieved using onSaveInstanceState() but as documentation
>> > says, this method is not a lifecycle method and hence the callback is
>> > not guaranteed.
>> >
>> > So i wanted to know if there is a way to save it using Bundle in
>> > onPause().
>>
>> --
>> 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]<android-developers%[email protected]>
>> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> 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 [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

Reply via email to