How To Access Flutter's Shared Preference File?
I am pretty new to flutter and currently, I am writing an app that needs to store key-value pairs to disk and read it each time the app is open.
I based on this document, using shared preference package, and it works fine. However, debugging is not easy, I am used to web development, and the similar idea, localStorage can be easily accessed and edited in run time using almost any browser such as Chrome, this feature makes it easy to develop and debug.
So my question is that is there some equivalence in Flutter development that I can easily edit the shared preference storage? One of the most needed functionality is to clear everything in the shared storage, so I can repeat running a clean program and debug.
Right now I can only do this by writing a functional code like
preferences.clear() and running it once, which is a pain.
I am using VSCode + Android AVD for Flutter development.
I found a work-around, by directly modify the files in Android virtual machine: Go to Android View -> Tool Windows -> device file explorer.
Here you will see all the files on the virtual phone device.
Navigate to your app folder, normally in data/data/com.example.yourprojectname
In shared_prefs folder, there is an XML file containing all the local key-value pairs, you can directly modify it, or delete it here.
PS: At the current stage, if the Flutter app has heavy features based on local (SQLite and shared preference), Android Studio is a much better-developing tool than VSCode, for much better virtual device inspection.
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?