Using the exact same code, if you wish.

On Thu, Feb 21, 2013 at 7:40 PM, Marcelo Corvezola <[email protected]> wrote:
> Normally I use something like the code below to load sharedPreference into
> an activity..
>
> loadPrefs();
>
> }
>
>
> private void loadPrefs() {
>
> SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
>
> boolean cbValue = sp.getBoolean("CHECKBOX", false);
>
> String name = sp.getString("NAME", "YourName");
>
> if(cbValue){
>
> cb.setChecked(true);
>
> }else{
>
> cb.setChecked(false);
>
> }
>
> et.setText(name);
>
> }
>
>
>
> How are preferences loaded in a fragment Acivity? thnx
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
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 4.6 Available!

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to