Tuesday 3 February 2015

What is the difference between getPreferences and getSharedPreferences in android ?

getPreferences(0) - will open or create a preference file with out giving a name specifically. By default preference file name will be the current Activity name. if some one knows this, any once can access getPreference() file using that activity name.  getSharedPreferences("name",0) - will open or create a preference file with the given name. If you want to create a preference file with a specific name then use this function. If you want multiple preference files for you activity, then also you can use this function.  Note: preferences file will be with .xml extension stored in data/data/preferences folder.

No comments:

Post a Comment