SimonVT / schematic
posted
Category: DataBase
Minimum SDK Level: ICS (15 | 4.0.3 - 4.0.4)

Badge

View in Github Github project information
Starred: 886
Forks: 88
Watchers: 36
Open Issues: 11

Snapshot pictures

No snapshot for this library yet.

Description

Usage

First create a class that contains the columns of a database table.

public interface ListColumns {

  @DataType(INTEGER) @PrimaryKey @AutoIncrement String _ID = "_id";

  @DataType(TEXT) @NotNull String TITLE = "title";
}

Then create a database that uses this column

@Database(version = NotesDatabase.VERSION)
public final class NotesDatabase {

  public static final int VERSION = 1;

  @Table(ListColumns.class) public static final String LISTS = "lists";
}

And finally define a ContentProvider

@ContentProvider(authority = NotesProvider.AUTHORITY, database = NotesDatabase.class)
public final class NotesProvider {

  public static final String AUTHORITY = "net.simonvt.schematic.sample.NotesProvider";

  @TableEndpoint(table = NotesDatabase.LISTS) public static class Lists {

    @ContentUri(
        path = Path.LISTS,
        type = "vnd.android.cursor.dir/list",
        defaultSort = ListColumns.TITLE + " ASC")
    public static final Uri LISTS = Uri.parse("content://" + AUTHORITY + "/lists")
  }