The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K…

Follow publication

Member-only story

Get Your Hand Dirty With Jetpack Datastore.

Lam Pham
The Startup
Published in
4 min readSep 20, 2020
Datastore implementation

In the previous blog, I have talked about what Datastore is, why it is created and also made a quick comparison with SharePreference. In this blog, we will see how to implement it.

Configuration

First, we need to configure some dependencies and plugins to our project.

Add this plugin on top of build.gradle file of the desired module:

plugins {
id "com.google.protobuf" version "0.8.12"
}

Next, add the protobuf convention to the same build.gralde file:

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.10.0"
}

generateProtoTasks {
all().each { task ->
task.builtins {
java {
option 'lite'
}
}
}
}
}

And then this dependency:

implementation  "com.google.protobuf:protobuf-javalite:3.10.0"

All these plugin, convention and library will help to generate java code from protobuf schema.

And now, we add datastore libraries to the project:

// Preferences DataStore
implementation…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Lam Pham
Lam Pham

Responses (1)

Write a response