Ariel,

Pass an existing instance of Activity / Service / whatever extending Context
to your class, as needed. Call getApplicationContext as necessary, to avoid
keeping a reference to something which may go away (such as an activity).


As a rule, never instantiate Activity or Service subclasses yourself:
Android does that for you, and hooks them up with the rest of the system for
proper functioning.

Another tempting thing, subclassing Context also requires special care so
it's hooked into the rest of the framework.


-- Kostya



2011/6/21 אריאל <[email protected]>

> yes because SharedPreferences must to extract Activity or Context
> how i repair this?
> 2011/6/21 Kostya Vasilyev <[email protected]>
>
>> It just depends on what "class settingM" is.
>>
>> I somehow have a feeling it's a subclass of Activity or Context, and you
>> instantiate it yourself with "new settingM" - is that true?
>>
>> -- Kostya
>>
>>   2011/6/21 אריאל <[email protected]>
>>
>>> yes i know this but how i used this from some activities?
>>>
>>>
>>> 2011/6/21 TreKing <[email protected]>
>>>
>>>>  On Mon, Jun 20, 2011 at 5:15 PM, אריאל <[email protected]>wrote:
>>>>
>>>>> so how i can to save setting with SharedPreferences and to get and set
>>>>> from other activity?
>>>>
>>>>
>>>> Read the documentation. Using SharedPreferences is very straight forward
>>>> and well-documented.
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------------------------------------
>>>> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
>>>> transit tracking app for Android-powered devices
>>>>
>>>> --
>>>> 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
>>>>
>>>   --
>>> 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
>>>
>>
>> --
>> 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
>>
>  --
> 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
>

-- 
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