1

我是 SugarORM 的新手,我试图保存记录。

Report report = new Report(SessionManager.getInstance().getUserid(),
                           assessmentContainer.getAssessmentTitle(),
                           getDateTimeNow(), response);
report.save();

在 SugarORM 给出的快速指南中,它似乎包含了上下文,但我不知道如何包含我的上下文,它与我的 Report 构造函数有冲突,所以我省略了它。

看起来它成功了,但似乎效率低下。知道有什么问题吗?看看我下面的日志。

02-01 14:10:32.736      903-903/com.usrs.jiarong.musrs I/Sugar﹕ on create
02-01 14:10:33.136      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.136      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.136      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.136      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.136      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.146      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.156      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.166      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.166      903-903/com.usrs.jiarong.musrs I/Sugar﹕ domain class
02-01 14:10:33.166      903-903/com.usrs.jiarong.musrs I/Sugar﹕ create table
02-01 14:10:33.166      903-903/com.usrs.jiarong.musrs D/Sugar﹕ Fetching properties
02-01 14:10:33.166      903-903/com.usrs.jiarong.musrs I/Sugar﹕ creating table REPORT
02-01 14:10:33.176      903-903/com.usrs.jiarong.musrs I/Sugar﹕ Report saved : 1
02-01 14:10:33.196      903-903/com.usrs.jiarong.musrs I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.
4

2 回答 2

1

在第一次启动sugarorm 时,它必须为数据库生成模型。确保您使用所需的表为您的包指定了 DOMAIN_PACKAGE_NAME。

于 2015-02-06T10:45:50.180 回答
0

在应用的 build.gradle 中编辑编译版本

compile 'com.github.satyan:sugar:1.5'

并且在模型中仅扩展 SugarRecord

我已经使用这种方法进行了修复。

于 2017-07-13T05:33:46.473 回答