Illustration by Virginia Poltrack

Since its introduction, ViewModel has become one of the most “core” Android Jetpack libraries. Based on our 2019 Developer Benchmarking data, over 40% of Android Developers have added ViewModels to their apps. If you’re not familiar with ViewModels, the reason why this is the case might not be clear: ViewModels promote better architecture by separating the data from your UI, making it easy to handle UI lifecycles while also improving testability. For a full explanation check out ViewModels: A Simple Example and the official documentation.

Because ViewModels are so fundamental, there’s been a lot of work over the past couple…

Illustration by Virginia Poltrack

Welcome to the second post of our WorkManager series. WorkManager is an Android Jetpack library that runs deferrable, guaranteed background work when the work’s constraints are satisfied. WorkManager is the current best practice for many types of background work. In the first blog post, we talked about what WorkManager is and when to use WorkManager.

In this blog post, I’ll cover:

  • Defining your background task as work
  • Defining how specific work should run
  • Running your work
  • Using Chains for dependent work
  • Observing your work’s status

I’ll also explain what’s going on behind the scenes with WorkManager, so that you can…


In the last blog post I explored a simple use case with the new ViewModel class for saving basketball score data during a configuration change. ViewModels are designed to hold and manage UI-related data in a life-cycle conscious way. ViewModels allow data to survive configuration changes such as screen rotations.

At this point, you might have a few questions about the breadth of what ViewModels do. In this post I’ll be answering:

  • Do ViewModels persist my data? TL;DR No. Persist as normal!
  • Are ViewModels a replacement for onSaveInstanceState? TL;DR No, but they are related so keep reading.
  • UPDATED 5/15/2019: How…


A little over two years ago, I was working on Android for Beginners; a class that takes students from zero programming to their first Android app. As part of the course, students build a very simple one screen app called Court-Counter.

Court-Counter is a very straightforward app with buttons that modify a basketball score. The finished app has a bug though; if you rotate the phone, your current score will inexplicably disappear.

What’s going on? Rotating a device is one of a few configuration changes that an app can go through during its lifetime, including keyboard availability and changing the…

Lyla Fujiwara

Android Developer Advocate @ Google

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store