I've released Python Android Preferences Mock, a small tool to simulate Android's SharedPreferences behavior using Python.
This library allows you to store and retrieve key-value pairs in a way that mimics SharedPreferences, but entirely within a Python environment. You don't need an Android device, emulator, or SDK to use it.
Why would you need this? It's primarily for two use cases:
- Testing: If you have business logic that relies on reading or writing preferences, you can now test that logic in isolation without setting up Android test environments. This can speed up your development workflow.
- Cross-Platform Logic: If you're building applications that share core logic between Android and other platforms (like web or desktop), this mock can help you develop and test that shared logic independently of the Android platform specifics.
The API is straightforward, mirroring the basic get/set operations you'd expect from SharedPreferences.
Check it out here:
Python Android Preferences Mock