Re: [android-developers] Re: How to access shared preference outside of Activity

2010-07-13 Thread Gene Augustine
I had asked the question " Is it possible to pass a variable to the
characters method event in the XMLReader.parse() of a SAX2 driver? If so
does anyone have an example? and was sent a message to use
PreferenceManager.getDefaultSharedPreferences().
I entered the statement:

 SharedPreferences mySharedPreferences =

PreferenceManager.getDefaultSharedPreferences(*this*);

and received the message :
“The method getDefaultSharedPreferences(Context) in the type PreferenceManager
is not applicable for the arguments (RSSHandler)”.
Am I missing something or is this not a solution?

Thanks,
Gene


On Sun, Jul 11, 2010 at 1:26 AM, Jeruliu  wrote:

> Thanks, you solved my problem, again.
>
> On Jul 9, 7:40 pm, Mark Murphy  wrote:
> > On Fri, Jul 9, 2010 at 5:03 AM, Jeruliu  wrote:
> > > Thanks, actually i need to access the shared preference in a class
> > > that extends from BroadcastReceiver, how can i call the context then?
> >
> > PreferenceManager.getDefaultSharedPreferences(), passing in the
> > Context supplied to you in onReceive() of your BroadcastReceiver.
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|
> http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>  >
> > _The Busy Coder's Guide to Android Development_ Version 3.1 Available!
>
> --
> 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 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

[android-developers] Re: How to access shared preference outside of Activity

2010-07-10 Thread Jeruliu
Thanks, you solved my problem, again.

On Jul 9, 7:40 pm, Mark Murphy  wrote:
> On Fri, Jul 9, 2010 at 5:03 AM, Jeruliu  wrote:
> > Thanks, actually i need to access the shared preference in a class
> > that extends from BroadcastReceiver, how can i call the context then?
>
> PreferenceManager.getDefaultSharedPreferences(), passing in the
> Context supplied to you in onReceive() of your BroadcastReceiver.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

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


Re: [android-developers] Re: How to access shared preference outside of Activity

2010-07-09 Thread Mark Murphy
On Fri, Jul 9, 2010 at 5:03 AM, Jeruliu  wrote:
> Thanks, actually i need to access the shared preference in a class
> that extends from BroadcastReceiver, how can i call the context then?

PreferenceManager.getDefaultSharedPreferences(), passing in the
Context supplied to you in onReceive() of your BroadcastReceiver.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

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


[android-developers] Re: How to access shared preference outside of Activity

2010-07-09 Thread Jeruliu
Thanks, actually i need to access the shared preference in a class
that extends from BroadcastReceiver, how can i call the context then?

On Jul 9, 4:21 pm, Mika  wrote:
> getSharedPreferences is defined in Context. Service is a Context also.
>
> On Jul 9, 9:08 am, Jeruliu  wrote:
>
> > Dear all,
>
> > I need to access the shared preference in a background service instead
> > of activity on phone boot up.
>
> > But getSharedPreferences function is define in the activity, so how
> > can i access the data without creating the activity?
>
> > Thanks.

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


[android-developers] Re: How to access shared preference outside of Activity

2010-07-09 Thread Mika
getSharedPreferences is defined in Context. Service is a Context also.

On Jul 9, 9:08 am, Jeruliu  wrote:
> Dear all,
>
> I need to access the shared preference in a background service instead
> of activity on phone boot up.
>
> But getSharedPreferences function is define in the activity, so how
> can i access the data without creating the activity?
>
> Thanks.

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