Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PreferenceDataStore in Android O

I read this article https://medium.com/@ianhlake/hidden-gems-of-android-o-7def63136629 . This is what is written there:

SharedPreferences is dead. Long live SharedPreferences.

Will SharedPreferences keep working in Android O ? Do we need to implement own mechanism for storing data in key value pairs by implementing PreferenceDataStore

Can anyone help how would be approach to implement new SharedPreferences using PreferenceDataStore& What is use case of developing own implementation ? Any drawback in current approach ?

like image 255
N Sharma Avatar asked May 02 '17 06:05

N Sharma


1 Answers

You should abandon bad habit of judging the book by its cover and instead of drawing conclusions from just catchy chapter title, simply read the mentioned post fully.

Shared Preferences are not even deprecated in Android Oreo and what Ian Lake mentions is an improvement, which allows your app to keep the same simple key/value pair API as it has now, but additionally be able to provide your own implementation of data store for said data (i.e. in Firebase, remote server, etc). If you do not need that, then you can simply use Shared Preferences as you did so far w/o any change in your code and with such use case nothing really changed.

like image 121
Marcin Orlowski Avatar answered Oct 12 '22 00:10

Marcin Orlowski