wood burning stoves 2.0*
The moose likes Android and the fly likes why there is need for shared preference. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "why there is need for shared preference." Watch "why there is need for shared preference." New topic
Author

why there is need for shared preference.

Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
Hi All,

I am new to Android Platform. I have just started coding in Android.

In the concept of Data storage every book talks about Shared Prefereces.

My understanding od shared preference is that Its used for storing primitive key value pairs in the file. But What I don't understand is we can accomplish this even using a

bundle in Intent. WHy do we need a seperate concept of shared preferences.

Please correct me if my concepts are wrong.


Thanks and Regards,
Anil Deshpande


Anil Deshpande
SCJP 1.5, SCWCD 1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Preferences are meant for storing user preferences and application status that needs to be persistent between app invocations. Sure you can write code that does the same, but why do so if Android has something built-in that works?


Ping & DNS - my free Android networking tools app
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 119
Ok, Can you cite an example for make the concept more apparant. If the preferences are being used for storing preferences, can't we do it in SQlite. Why preferecnes?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Anil Deshpande wrote:If the preferences are being used for storing preferences, can't we do it in SQlite. Why preferecnes?


Ulf Dittmer wrote:Sure you can write code that does the same, but why do so if Android has something built-in that works?


Also, defining the preferences in the xml/preferences.xml file (instead of coding them up yourself) provides you with a nice preferences screen for very little work - very handy.

See http://www.androidguys.com/2008/09/29/whats-your-preference-part-one/, http://www.androidguys.com/2008/10/07/whats-your-preference-part-two/ and http://www.ibm.com/developerworks/xml/library/x-androidstorage/index.html for more information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why there is need for shared preference.
 
Similar Threads
how to store and retrieve array list value in shared preference in android
is their need of new platform and what dou you think next ?
How did you start or know about Android?
Android Begginer
SharedPreference not working