49238

What is the difference between Preferences and SharedPreferences in Android?

Question:

What is the difference between java.util.prefs.Preferences and android.content.SharedPreferences? Looks like they are for similar things - you can put and get a value by a key in both of them, but Preferences looks like something more difficult and belongs more to the OS than to an app.

Answer1:

Preferences is a core java class <a href="https://developer.android.com/reference/java/util/prefs/Preferences.html" rel="nofollow">link1</a>

<blockquote>

<strong>java.util.prefs.Preferences :</strong> This class allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store.

</blockquote>

SharedPreferences is an android specific interface <a href="https://developer.android.com/reference/android/content/SharedPreferences.html" rel="nofollow">link2</a>

<blockquote>

<strong>android.content.SharedPreferences :</strong> Interface for accessing and modifying preference data returned by getSharedPreferences(String, int). For any particular set of preferences, there is a single instance of this class that all clients share.

</blockquote>

Recommend

  • Get the next href in a list in another file with jQuery?
  • Unable to link my own static libraries
  • Set up the Android-Facebook sdk for Netbeans
  • Multiprocessing in Python: how to implement a loop over “apply_async” as “map_async” using a callbac
  • Create child Window of another process's HWND? (e.g. screensaver preview)
  • LatLong falls within a given polygon in D3 + Leaflet
  • opengl window freezing during move/resize
  • how to resolve OAuthException: (#100)
  • back button function for phonegap windows phone 7
  • Can long-polling be achieved in Restlet by just making the thread sleep?
  • Retaining data after updating application
  • Angular2 component view does not update on value change via method
  • CakePHP ACL tutorial initDB function warnings
  • Unable to get column index with table.getColumn method using custom table Model
  • How to suppress a dialog
  • Can I display google adwords (AdView) in javafx on android
  • req.body is undefined - nodejs
  • Obtain ObjectIdHex value from mgo query
  • Can I make an Android app that runs a web view in Chrome 39?
  • Symfony2: How to get request parameter
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Apache 2.4 - remove | delete | uninstall
  • Akka Routing: Reply's send to router ends up as dead letters
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Cannot Parse HTML Data Using Android / JSOUP
  • SetUp method failed while running tests from teamcity
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How do you join a server to an Active Directory (domain)?
  • Understanding cpu registers
  • Java static initializers and reflection
  • How does Linux kernel interrupt the application?
  • Authorize attributes not working in MVC 4
  • unknown Exception android
  • Busy indicator not showing up in wpf window [duplicate]
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF