Database example app with Room ORM

With Android Architecture Components getting a stable 1.0 version, there are now no excuses of not using it ๐Ÿ™‚ Along with handling lifecycle events, realtime data updates in UI (ViewModel with LiveData) and pagination of loaded data (Paging), comes Room – small, yet powerful SQLite ORM. In this post I’m gonna demonstrate its core capabilities on an example Android application.

Remember those times implementing SQLiteOpenHelper and checking SQL queries in run-time? Good news is that you don’t have to do it anymore! Room performs compile-time checks on your SQL queries and you don’t have to write any SQLite code which is not in a direct relation with your data queries. Great, lets use it!

First of all, Room is a part of Architecture Components, which means it works really well with ViewModel, LiveData and Paging (but does not depend on them!). Also, RxJava and Kotlin are perfectly fine too. In order to add Room to the project, I’m adding the following lines in app’s build.gradle file:

    // Room
    implementation "android.arch.persistence.room:runtime:1.0.0"
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0"

Check for the latest library versionย here.

Additionally, provide a location of DB’s schema in defaultConfig scope. This way you can always check how it looks, maybe decide to modify your tables once you notice something in scheme.

   javaCompileOptions {
        annotationProcessorOptions {
            arguments = ["room.schemaLocation":
                                 "$projectDir/schemas".toString()]
        }
    }

Continue reading Database example app with Room ORM

Like and share:

Look Counter app and more!

Hi there,

It’s been a long time since I talked about my app’s release, but finally this day came! Today, I want to present you Look Counter – a simple app for counting how many times a day you have turned on and unlocked your phone (or tablet). It counts this in background and displays the latest numbers on the main view. You, as a user, can delete this data at any moment of time (Clear all Data option, with a quick Undo if you change your mind).

Look Counter app screenshots

 

I’ve put an About view, if somebody is confused with the minimalist design and doesn’t follow what those numbers in circles mean, or maybe, wants to contact me right away, and say that counting doesn’t work for him at all! ๐Ÿ˜›

Anyway, the source code is on GitHub, so you can check what’s inside and grab tasty pieces, as well as point me at my mistakes ๐Ÿ˜‰
Continue reading Look Counter app and more!

Like and share:

Tutorial: How to use a Handler?

Hello,

Today I will show you how to benefit from Handlers in Android ๐Ÿ™‚

First of all, Handlers aren’t some new concept, they were there long ago. How long? Well, from API level 1. Still, I always felt Android developers don’t use them enough, me included.

When I’ve discover the brilliance of Handlers, I was surprised how handy they are and how easy is to use them.

So, what does a Handler do? A few things, really.
Continue reading Tutorial: How to use a Handler?

Like and share:

Android Color Picker library

Hi, everybody!

Today I wanted to share a very good news with you. I have finally finished implementing changes to my fork of android-color-picker library. It is on github already, so feel free to Watch & Star ๐Ÿ˜‰

Color Picker screenshotAs written in README, this is just a small library for very intuitive and interactive color picking. Why should you use my fork and not the original library? Well, with Android 3+ came the era of fragments and you should use fragments for better UX and device compatibility.
Continue reading Android Color Picker library

Like and share: