/DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

Primary LanguageJavaMIT LicenseMIT

Image

JCenter Android Weekly Android Arsenal

A robust, powerful, and very simple ORM android database library with annotation processing.

The library is built on speed, performance, and approachability. It not only eliminates most boiler-plate code for dealing with databases, but also provides a powerful and simple API to manage interactions.

Let DBFlow make SQL code flow like a steady stream so you can focus on writing amazing apps.

What sets this library apart:

  1. Many, many unit tests on nearly every feature.
  2. Built on maximum performance using annotation processing, lazy-loading, and speed-tests here
  3. Built-in model caching for blazing fast retrieval and ability to define own cache.
  4. Powerful and fluid SQL-wrapping statements
  5. Triggers, Views, Indexes, and many more SQLite features.
  6. Seamless multi-database support.
  7. Direct-to-database parsing for data such as JSON
  8. Flexibility in the API enabling you to override functionality to suit your needs.
  9. ContentProvider generation using annotations

Applications That Use DBFlow

If you wish to have your application featured here, please file an issue.

  1. Anonymous 1: An application that has over 1.5 million active installs
  2. Anonymous 2: An application that will have over 1 million active installs
  3. University of Oslo DHIS2 Android SDK

Changelog

2.1.0

  1. Library now is on jCenter()/bintray!
  2. Full Enum Support. Note: they must be standard columns. We do not support foreign key or primary key for enums.
  3. Can now define inherited properties to use as columns. Note: They can only be normal, accessible to the subclass columns for now. Just define @Table(inheritedColumns = {@InheritedColumn(column = @Column, fieldName = "fieldName")}.
  4. Bug Fixes, readme enhancements, Logging Improvements, and improved code commenting
  5. Function support for SQLite methods in a condition such that date(myColumn1)=1433872730 can be written as Condition.columnsWithFunction("date", "myColumn1").eq(1433872730)
  6. Fixed an issue where Condition instead of SQLCondition were leftover as a param in a few methods.

2.0.0

  1. Massive, massive changes to the library.
  2. For all changes, check out the migration guide here

for older changes, from other xx.xx versions, check it out here

Usage Docs

For more detailed usage, check out these sections:

Getting Started

Tables and Database Properties

SQL Statements Using the Wrapper Classes

Conditions

Transactions

Type Converters

Powerful Model Caching

Content Provider Generation

Migrations

Model Containers

Observing Models

Tables as Lists

Triggers, Indexes, and More

Screencasts

Listed here are tutorial screen casts for DBFlow. If more are created, they may go into the usage docs.

  1. DFlow-Installing by @tsuharesu

Including in your project

Add the library to the project-level build.gradle, using the apt plugin to enable Annotation Processing:

  apply plugin: 'com.neenbedankt.android-apt'

  dependencies {
    apt 'com.raizlabs.android:DBFlow-Compiler:2.1.0'
    compile "com.raizlabs.android:DBFlow-Core:2.1.0"
    compile "com.raizlabs.android:DBFlow:2.1.0"
  }

We only use reflection pretty much one time throughout the whole library, so this class is the only one needed.

Gotchas/Compatibility

For GSON and RetroFit compatibility check out #121.

Due to this library using a custom maven repo, to speed up build times when using this library, you should run in --offline mode except for when updating dependencies. To enable this setting in Android Studio, ensure the option is checked in: Preferences->Build,Executor,Deployment->Build Tools->Gradle->Offline Work

Pull Requests

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults.
  2. If its a feature, bugfix, or anything please only change code to what you specify. DO NOT do this: Ex: Title "Fixes Crash Related to Bug" includes other files that were changed without explanation or doesn't relate to the bug you fixed. Or another example is a non-descriptive title "Fixes Stuff".
  3. Pull requests must be made against develop branch.
  4. Have fun!

Maintainers

agrosner (@agrosner)

Contributors

wongcain

mozarcik

mickele

intrications

mcumings

ktzouno