· 2 min read Posted by Kevin Galligan

Android’s Room Db on iOS

I figured I’d see if we could try Android’s new Room db framework on iOS. That should be pretty simple, right? Well maybe not...

(Crosspost from medium.com/@kpgalligan)

I’m stuck in NYC because of prior commitments, watching all the fun at I/O. That’s OK. Some interesting stuff came out yesterday.

TL;DR One of the reasons we’re pushing Doppl is because you can include popular libraries easily. It took about 90 minutes to get Room running on iOS. Clone this and try it out.

The “traditional” Android docs from Google were promoting tools and concepts that pretty much nobody was using anymore. ContentProvider (for same process data), AsyncTask, Loader, etc. The new architecture stuff looks like a good step forward that incorporates much of what the community has been promoting for the last few years.

I’ve done a lot of Android DB work over the years. See blog post from talk for more info. As we just released a blog post about Doppl and Android architecture on iOS, I figured I’d see if we could try Android’s new Room db framework on iOS. That should be pretty simple. The lifecycle stuff will take some more surgery, as parts of that framework incorporate Fragment and Activity, and I assume portions of that won’t make sense in an iOS context, but I think that’ll work out as well.

I don’t think the source for the new architecture stuff is available yet, but it is if you know where to look. Sorry in advance (but the pom says apache, so…).

I think I’ll do a longer blog post later about Room compared to other db libs, but the short version is it’s an interesting addition.

Converting to iOS was pretty straightforward. Converting the sample app to Room probably took a little longer, but was simpler because there are docs 😉 Do not try to use this for anything other than running the sample. I found the source, but not the tests, so I wouldn’t call this production ready.

Also, yes, I know the sample app does I/O work in the main thread, but it’s a sample app. I like that Room forces you to declare that in the builder.

Clone the sample app and look for “TheRoom” branch.

As always, hiring.

And looking to expand our family of Kotlin Multiplatform experts.