百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

schematic

> 编程语言
开源

自动生成内容提供者

1.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

自动生成内容提供者

示意图 ========== 自动生成由 SQLite 数据库支持的 ContentProvider。 使用 ===== 首先创建一个包含数据库表列的类。 java public interface ListColumns { @DataType(INTEGER) @PrimaryKey @AutoIncrement String ID = "id"; @DataType(TEXT) @NotNull String TITLE = "title"; } 然后创建一个使用此列的数据库 java @Database(version = NotesDatabase.VERSION) public final class NotesDatabase { public static final int VERSION = 1; @Table(ListColumns.class) public static final String LISTS = "lists"; } 最后定义一个 ContentProvider java @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 = "lists", type = "vnd.android.Cursor.dir/list", defaultSort = ListColumns.TITLE + " ASC") public static final Uri LISTS = Uri.parse("content://" + AUTHORITY + "/lists"); } 表列注解 ------------------------ java @AutoIncrement @DataType @DefaultValue @NotNull @PrimaryKey @References @Unique 定义 Uri --------------- @ContentUri 注解用于当 Uri 不变时。 java @ContentUri( path = "lists", type = "vnd.android.Cursor.dir/list", defaultSort = ListColumns.TITLE + " ASC") public static final Uri LISTS = Uri.parse("content://" + AUTHORITY + "/lists"); 如果 Uri 根据某个值创建,例如 ID,则使用 @InexactContentUri。 java @InexactContentUri( path = Path.LISTS + "/#", name = "LISTID", type = "vnd.android.Cursor.item/list", whereColumn = ListColumns.ID, pathSegment = 1) public static Uri withId(long id) { return Uri.parse("content://" + AUTHORITY + "/lists/" + id); } 加入项目 ========================= groovy dependencies { annotationProcessor 'net.simonvt.schematic:schematic-compiler:{latest-version}' compile 'net.simonvt.schematic:schematic:{latest-version}' } 许可 =========== Copyright 2014 Simon Vig Therkildsen 根据 Apache 许可证,版本 2.0("许可";您不得使用本文件,除非…

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Java

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言