SEARCH

Linux Install

Android

Linux Tools

Linux AV

Linux Memo

WINDOWS

PROGRAM

動画 Memo

音楽 Memo

モバイルアプリ Memo

FILE FORMAT

PROTOCOL

DEVICE

BookMark

その他


Android/DBFlow   

android 用 ORM

DBFlow

install

build.gradle(Module: app)

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

def dbflow_version = "4.0.0-beta1"
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'

    apt 'com.github.Raizlabs.DBFlow:dbflow-processor:4.0.0-beta1'
    compile "com.github.Raizlabs.DBFlow:dbflow-core:4.0.0-beta1"
    compile "com.github.Raizlabs.DBFlow:dbflow:4.0.0-beta1"
}

build.gradle(Project: PROJECTNAME)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://www.jitpack.io" }
    }
}

model

@Table(database = Db.class)
public class User extends BaseModel{
    @PrimaryKey(autoincrement = true)
    public long id;

    @Column
    public String name;

    @Column
    public String email;

    @Column
    public Integer is_delivery;
}

DB

@Database(name = Db.NAME, version = Db.VERSION, generatedClassSeparator = "_")
public class Db {
    public static final String NAME = "Db";
    public static final int VERSION = 1;
}

app

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FlowManager.init(this);

        User user = new User();
        user.name = "david";
        user.email = "david@caffeinecat.net";
        user.save();
    }
}