O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subjects for Settings

Having Settings management code scattered around might be a bit unwieldy; so, we will create a separate class, called Settings, for this purpose:

public class Settings {}

Also, we will ensure that it will be instantiated only once using a singleton pattern:

public class Settings {    private static Settings INSTANCE;    private Settings(Context context) {        SharedPreferences preferences             = PreferenceManager.getDefaultSharedPreferences(context);    }    public synchronized static Settings get(Context context) {        if (INSTANCE != null) {            return INSTANCE;        }        INSTANCE = new Settings(context);        return INSTANCE;    }}

The Settings class will expose two Subjects: one will be used to retrieve followed symbols and the second will be used to get ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required