toothpick.smoothie.provider.SharedPreferencesProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smoothie Show documentation
Show all versions of smoothie Show documentation
'Toothpick package providing Android providers'
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