shared_preferences_android
2.5.5, released 9 days ago by flutter.dev
Android backend for the shared_preferences plugin, storing key‑value data on Android devices.
What it does
It implements the shared_preferences API for Android, allowing data to be saved using either the native Android SharedPreferences or the newer DataStore Preferences. The package is endorsed and automatically included when using shared_preferences.
AI-written summary of version 2.5.4, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need persistent key‑value storage on Android via shared_preferences
- You want to use SharedPreferencesAsync or SharedPreferencesWithCache with Android‑specific options
Skip it when
- You need cross‑platform storage without adding platform‑specific code
- You require encrypted or secure storage
Strengths
- Official endorsed federated plugin
- Supports both Android SharedPreferences and DataStore backends
- Zero‑config when using shared_preferences
Weaknesses
- Android‑only; no effect on iOS, web, etc.
- Adds native Kotlin/JNI layer, increasing app size
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
const SharedPreferencesAsyncAndroidOptions options = SharedPreferencesAsyncAndroidOptions(
backend: SharedPreferencesAndroidBackendLibrary.SharedPreferences,
originalSharedPreferencesOptions: AndroidSharedPreferencesStoreOptions(
fileName: 'the_name_of_a_file',
),
);Alternatives
Packages that do the same job and could replace shared_preferences_android.
- flutter_secure_storage
Provides encrypted storage when security is required
93Compare - hive_ce
Offers fast, pure‑Dart key‑value storage without native code
96Compare
Works with
Packages commonly used together with shared_preferences_android: ones it builds on, ones built on it, and its own family.
- jnishared_preferences_android depends on itProvides Dart/Flutter bindings to call native Java code via JNI.
- shared_preferences_windowsSame familyWindows platform implementation for shared_preferences
- shared_preferencesBuilt on shared_preferences_androidFlutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.