Connect with us


Android dev Must-Know data format: Protocol Buffers

The Google Advocated Data Format to Serialize Information in Android.

Protocol Buffer is not a new data format introduced by Google. I shared about it in 2017, as a way of transferring data payloads other than REST JSON format that we are all familiar with.

In the recent introduction of Jetpack DataStore, a replacement for Android popularly known SharedPreferences, Protocol Buffer is now introduced as a means to store more comprehensive data. The two articles n Android Developer Documentation below mentioned it.

  1. DataStore
  2. Prefer Storing Data with Jetpack DataStore

This essentially makes it important for Android Developer to know what is Protocol Buffer.

The documentation above, does point to the Protocol Buffers tutorial. However, I can’t find any guide on how to set that up on Android Studio to generate the Protocol Buffer file.

Hence I’m sharing here to make it easier to follow along when one needs it. But before that….

What is Protocol Buffer (aka Protobuf)?

This is a Google Introduce data model format, that can be used to generate different programming serialization code

The Protocol Buffers tutorial will provide a guide on how to do so separately from mobile development.

From there, one can imagine, iOS developers can use the Swift Proto Model to read and share the same Proto Data File/Stream that is used by its respective Android development.

One benefit of using this file format is, if we follow the rule strictly, it is relatively forward and backward compatible. Hence, this might be the reason Google now advocates Protobuf as the file format for its Jetpack DataStore.

Full Article: Elye @ Mobile App Development Publication