Read / Write Configuration Information using Preferences
Learn:
- Preferences
Requirements
- Android smartphone or emulator
Android provides several options for you to save persistent application data. SharedPreferences provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans, floats, ints, longs, and strings. This data will persist across user sessions (even if your application is killed).
Run the preference_write.py to save the value and subsequent running of preference_read.py will retrieve the stored value.
preference_write.py
putstoreval is assigned to the key mystoreval and stored in the preferences file mypref.txt
preference_read.py
More information about the preferences api
Scan the script to your smartphone using the Test EMANT380 app or download to PC/Emulator