getSharedPreferences

by Brad Gies » Sat, 06 Dec 2008 03:02:38 GMT


Sponsored Links
 Can someone clarify how to use getSharedPreferences(String
< http://code.google.com/android/reference/java/lang/String.html> ;  name, int
mode)  ?

 

I have created a preferences.xlm file, added some Boolean preferences, can
edit them from an activity, but I can't seem to figure out how to get the
values into another activity in my application using getSharedPreferences. 

 

I know. it should be simple. and I'm sure it is. but I can't figure out what
name to put in or what mode. 

 

Any help or links to sample code appreciated.

 

 

Sincerely,

 

Brad Gies

 

 

-----------------------------------------------------------------

Brad Gies

27415 Greenfield Rd, # 2,

Southfield, MI, USA

48076

-----------------------------------------------------------------

 

Moderation in everything, including abstinence

 


--~--~---------~--~----~------------~-------~--~----~



getSharedPreferences

by Mark Murphy » Sat, 06 Dec 2008 03:12:12 GMT


 


Use PreferencesManager.getDefaultSharedPreferences() instead. This will 
return the SharedPreferences object that lines up with the preference 
screen system.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.9 Available!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


getSharedPreferences

by Brad Gies » Sat, 06 Dec 2008 11:45:53 GMT


 Thank Mark... as always your advice is exactly what I needed. :) 

By the way, I just downloaded the 1.9 version of your book (wondered what
happened to 1.5... 1.8 but that's another question), and it is even better
than it was... except for one thing.... That's a god awful color of
green.... The red/maroon color you had before was much nicer :). 

But.... I guess if that's the biggest complaint I've got about the book that
pretty well says it all :). I hope you're doing well with it. To be honest,
I've gotten about ten times my moneys' worth from the book in free advice on
this list from you, so if I make money from my app, I'll buy a few copies of
it for some other developers ;). 




Sincerely,
 
Brad Gies
 
 
-----------------------------------------------------------------
Brad Gies
27415 Greenfield Rd, # 2,
Southfield, MI, USA
48076
www.bgies.com  www.truckerphone.com 
www.EDI-Easy.com  www.pricebunny.com
-----------------------------------------------------------------
 
Moderation in everything, including abstinence
-----Original Message-----
From: android-developers@googlegroups.com
[EMAIL PROTECTED] On Behalf Of Mark Murphy
Sent: Friday, December 05, 2008 2:12 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: getSharedPreferences





Use PreferencesManager.getDefaultSharedPreferences() instead. This will 
return the SharedPreferences object that lines up with the preference 
screen system.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.9 Available!



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Reported memory usage

So I think I've finally plugged all my memory leaks (tip: watch out for 
Handlers which outlive your Activity), and overall, my apps seem to be doing 
pretty well in this regard. But in the last couple of days I've had a user 
complaining that one app is using far too much memory, and furthermore that 
it gets worse as the app is running longer (it has a clock widgets, so it'll 
stay resident in memory if things aren't too tight). He's saying 
it's frequently at 40-50MB, and will climb over 80MB. 

Now, you and I both know that this isn't possible given the constraints of 
the Dalvik heap. Following up with this user, I learn that he's getting 
these numbers from Process Monitor Widget (PMW), and sure enough, when I 
install it I see something similar. I reached out to the dev of PMW, and he 
informs me that he's getting the figures "from the kernel process 
description file located @ /proc/$pid/stat." Not being a Linux kernel guy, 
I'm not well versed on such matters, but I'm strongly suspecting that it's 
not valid for Dalvik processes.

For example: right now the app in question on my N1 is showing 57MB in PMW, 
while a heap dump in DDMS shows 3.4MB. This latter number seems quite 
reasonable to me, but I don't feel OK in just going back to this user and 
saying "PWM, and other apps of its ilk, are just wrong." That could easily 
develop into a "he said, she said" situation.

So, I'm hoping somebody here - ideally someone on the framework team (you 
here, Romain? ;^) ) - can speak more authoritatively about this. And 
hopefully, other devs that face this situation in the future can be better 
equipped to deal with it. Anyone?

String

-- 

2. How to get the list of notifications dispalyed on status bar......

Hi all

Is it possible to retrieve the list of notifications/updates displayed
on status bar?Does notification manger keeps a track of whatever
notifications it displays and stores them somewhere if yes then can we
get the list of notifications displayed?

-- 

3. How to load resources like texture images & sound files in native code?

4. Android Test Market

5. why doesn't google provide us a pure C/C++ SDK for android?

6. Dynamically build status bar icon from layers in Java, but can't figure-out resource ID

7. Problem with audio recording