All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toothpick.smoothie.provider.SharedPreferencesProvider Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package toothpick.smoothie.provider;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import javax.inject.Inject;
import javax.inject.Provider;

public class SharedPreferencesProvider implements Provider {
  Application application;
  String preferencesName;

  @Inject
  public SharedPreferencesProvider(Application application) {
    this(application, null);
  }

  public SharedPreferencesProvider(Application application, String preferencesName) {
    this.application = application;
    this.preferencesName = preferencesName;
  }

  @Override
  public SharedPreferences get() {
    if (preferencesName != null) {
      return application.getSharedPreferences(preferencesName, Context.MODE_PRIVATE);
    }
    return PreferenceManager.getDefaultSharedPreferences(application);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy