Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open jetpack DataStore file (.preferences_pb)

I am trying out new jetpack DataStore library . I saved data using the library . This created a file settings.preferences_pb in app data directory (/data/data/my.package.name/files/datastore/settings.preferences_pb) . setting is the file name given by me . The data doesn't show properly with a text viewer . I can make out Key name but the value is garbage . How do I open this file and view it ?

Here is the drive link for file settings.preferences_pb

like image 752
Manohar Avatar asked Nov 06 '22 05:11

Manohar


1 Answers

Reference: https://medium.com/swlh/get-your-hand-dirty-with-jetpack-datastore-b1f1dfb0a5c1


The protobuf files will be located in /data/data/{application.package}/files/datastore/ . These are the protobuf formatted files, so we can not read them with an ordinary editor. To decode the files, we can use protoc command line.

To be able to use protoc command, we have to pull these files to our workstation’s space using adb command

For preference datastore

protoc --decode_raw < app_name.preferences_pb

The result will be similar to this:

1 {
    1: "app_name"
    2 {
        5: "Datastore sample"
    }
}
1 {
    1: "is_demo_mode"
    2 {
        1: 1
    }
}

Note: value 1 of is_demo_mode represents a true

like image 90
Shubham Agarwal Avatar answered Nov 14 '22 21:11

Shubham Agarwal