skip to Main Content

I use the internal shared preferences to store key/values on an Android device. I wanted to have a look at this data directly using a file explorer but I cannot find where it is stored physically. Most apps have an own directory on Android/data but there is no folder for my Flutter app.

Do you have an idea where the data is stored locally?

Thanks in advance.

Edit (To make my problem clearer):

I need to access this data from outside app. A user of my app is not able to start the app anymore for some reasons. I want him to send me the internal data for debugging purposes.

So is it possible to fetch the related files in any way without the app self?

2

Answers


  1. On native android its stored inside the data folder. The path will be something like

    /data/data/<your_package_name>/shared_prefs/YOUR_PACKAGE_NAME_preferences.xml
    

    On Flutter projects its stored inside the same folder but with fixed name FlutterSharedPreferences.xml
    Something like

    /data/data/<your_package_name>/shared_prefs/FlutterSharedPreferences.xml
    

    Edited in response of updated question – 05/01/2023

    If your app is relying heavily on sharedpreferences then I don’t think there is a way to get it from outside your app. But I have an idea which you can try.
    Try this package https://pub.dev/packages/flutter_logs.
    This can create log files in file system. If your app is currently crashing after opening you can try to put this log code to write down the sharedpreferences inside the log file. Then you can setup some code to send the logs by email.

    But there are few catches in this approach.

    1. You have to set this code in initial screen like splashscreen and wait until this process is complete.
    2. You have to send this updated apk and ask your user to install it.

    I suggest you to implement this anyhow as in future you might get stuck in similar situation if you are relying on sharedpreferences.

    Hope this helps.

    Login or Signup to reply.
  2. SharedPreferences are stored in an xml file in the app data folder, i.e.

    /data/data/YOUR_PACKAGE_NAME/shared_prefs/
    

    You can access these from Device File Explorer Tab inside the Android Studio IDE on the right side :
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search