greendao

GreenDao3.0的简单使用

匿名 (未验证) 提交于 2019-12-03 00:30:01
首先配置grendao 1、导入相应的包 [java] view plain copy compile 'org.greenrobot:greendao:3.0.1' compile 'org.greenrobot:greendao-generator:3.0.0' 2、配置项目的Gradle 'org.greenrobot:greendao-gradle-plugin:3.0.0' 3、配置app的Gradle [java] view plain copy 'org.greenrobot.greendao' 1 'com.example.anonymous.greendao.gen' 'src/main/java' 3.编写实体类(对应的是数据库的每张表) [java] view plain copy @Entity public class @Id private private @Entity:将我们的java普通类变为一个能够被greenDAO识别的数据库类型的实体类 @Id:通过这个注解标记的字段必须是Long类型的,这个字段在数据库中表示它就是主键,并且它默认就是自增的 就这么简单含有两个字段的实体类 然后点击这个按钮 builder完之后会有两个地方发生了变化 这是GreenDao自动为你生成的,路径就是你在gradle中配置的路径 现在只有一个User表

kotlin写的音视频app(已开源)

匿名 (未验证) 提交于 2019-12-02 23:43:01
目前项目持续更新重构中(目前项目已经转型到kotlin了) Life is a Multimedia information app based on Material Design Kotlin + MVP + RxJava + Retrofit + Dagger2 + GreenDAO + Glide life 是一个多媒体信息app,基于Material Design Kotlin + MVP + RxJava + Retrofit + Dagger2 + GreenDAO + Glide 做这款app主要是出于Android日常开发中或多或少的都会仿着ios的样式来写ui(可能设计师就做了一份ios交互设计,android只能跟着去写相同ui),完全舍弃了MD风格,第一出于学习目的做的,第二出于想写一个完全按照MD风格的App。 目前包括以下内容: 视频来自:开眼 http://www.eyepetizer.net/汇集各种炫酷视频 音乐来自:余音 http://app.mi.com/details?id=fm.wawa.mg/文艺骚年专属 文章来自:余音 http://www.wufazhuce.com/韩寒主编和监制 全景图片来自:kuula https://kuula.co/主要是图片质量很高 tips 1.本项目目前只是在开发测试阶段,发现bug或有好的建议欢迎

ORM performance: is greenDAO faster than ORMLite?

风格不统一 提交于 2019-12-02 14:18:23
I've been using ORMLite in my application and I was considering whether to move to greenDAO. Performance is a huge part of that decision, and greenDAO's Features page says: For the same given entity, greenDAO inserts and updates entities over 2 times faster, and loads entities 4.5 times faster for loading entities than ORMLite. ... (Figures and chart updated 10-23-2011) I thought ORMLite's config file generation step should remove the need for reflection at runtime. The ORMLite changlog suggests that the greenDAO benchmark was done after the config file feature was released, but the greenDAO

Android - SQLite - no such column error (greenDAO)

北战南征 提交于 2019-12-02 09:31:04
I created my table structure with greenDAO and when updating the following table, I'm getting the follwing error: android.database.sqlite.SQLiteException: no such column: BODY_LOG_ENTRY._id: , while compiling: UPDATE BODY_LOG_ENTRY SET 'BODY_LOG_ENTRY._id'=?, 'BODY_LOG_ENTRY.FK_DAY'=?, 'BODY_LOG_ENTRY.DAY_ORDER'=?, 'BODY_LOG_ENTRY.DESCRIPTION'=?, 'BODY_LOG_ENTRY.BODY_WEIGHT'=?, 'BODY_LOG_ENTRY.BODY_SIZE'=?, 'BODY_LOG_ENTRY.BODY_FAT_FORMULA'=?, 'BODY_LOG_ENTRY.BODY_FAT_FORMULA_DATA1'=?, 'BODY_LOG_ENTRY.BODY_FAT_FORMULA_DATA2'=?, 'BODY_LOG_ENTRY.BODY_FAT_FORMULA_DATA3'=?, 'BODY_LOG_ENTRY.BODY

最受欢迎的5个Android ORM框架

社会主义新天地 提交于 2019-12-02 06:37:34
在开发Android应用时,保存数据有这么几个方式, 一个是本地保存,一个是放在后台(提供API接口),还有一个是放在开放云服务上(如 SyncAdapter 会是一个不错的选择)。 对于第一种方式,即本地数据存储,如嵌入式 SQLite ,你可以选择直接使用SQL语句、Content Provider 或 ORM(对象关系数据映射)。 对于 Android 应用的开发,主要是使用Java语言,所以适用于Java语言的一些ORM,也能移植于 Android 平台上。 下面是5个可用ORM的总体介绍: 1. OrmLite OrmLite 不是 Android 平台专用的ORM框架,它是Java ORM。支持JDBC连接,Spring以及Android平台。语法中广泛使用了注解(Annotation)。 官方网站:http://ormlite.com/sqlite_java_android_orm.shtml 2. SugarORM SugarORM 是 Android 平台专用ORM。提供简单易学的APIs。可以很容易的处理1对1和1对多的关系型数据,并通过3个函数save(), delete() 和 find() (或者 findById()) 来简化CRUD基本操作。 要启用SugarORM,需要在你的应用程序 AndroidManifest.xml 配置中添加如下meta

Android java: OutOfMemory while inserting a huge List into the database SQL

眉间皱痕 提交于 2019-12-02 05:51:48
问题 I'm just working on an Android Project where an ORM greendao is used. It allows me to insert a number of entities (which are obviously objects) into the database at once (in one transaction). In practice there's a method insertOrReplaceInTx(...) which takes as a parameter a collection, given a List of objects. The problem is that my list has sort of 12000 objects and an insert leads from time to time to an OutOfMemory Exception. I'm thinking of a smart way to solve the problem and prevent

Android java: OutOfMemory while inserting a huge List into the database SQL

守給你的承諾、 提交于 2019-12-02 01:44:45
I'm just working on an Android Project where an ORM greendao is used. It allows me to insert a number of entities (which are obviously objects) into the database at once (in one transaction). In practice there's a method insertOrReplaceInTx(...) which takes as a parameter a collection, given a List of objects. The problem is that my list has sort of 12000 objects and an insert leads from time to time to an OutOfMemory Exception. I'm thinking of a smart way to solve the problem and prevent future OOM. The only idea which comes to my mind is to split the huge collection into sort of

GreenDao Many to Many Relation

佐手、 提交于 2019-12-01 22:14:49
I use Greendao for my database mapping in Android. So far everything works great. But now I have the following problem: I have a Cluster and leaf Objects. A cluster contains many leaf objects. If a cluster is zoomed it can split up in more clusters and more leafs. This is not a strict tree relationship it is more that a big cluster has a lots of leafs but a small cluster can have a subset of this leafs. Basically a cluster has many leafs but leafs also are in multiple clusters, since the id of a leaf is unique and the relation to the cluster is saved in the leaf a leaf can only be in one

How to clean/delete greenDao database

半城伤御伤魂 提交于 2019-12-01 02:54:50
Currently I'm doing it like this: DaoMaster.dropAllTables(getDb(), true); DaoMaster.createAllTables(getDb(), true); but then, when I'm trying to add entity to the database, I'm getting crash log saying that this table isn't exist Edit1: I know that it happens because the db is locked and tables wasn't created yet. So I'm reducing this problem to the problem - how to know if the tables are locked in grrenDao/Sqlite? Until now, I don't worry if tables are locked or not; in my case, i do the following and it works: First, when App.onCreate executes, I make the standard initializations. T

GreenDao

扶醉桌前 提交于 2019-11-30 09:41:54
public class GreenDaoUtil { private static DaoSession daoSession = null; public static DaoSession getDaoSession(Context context) { if (daoSession == null) { daoSession = DaoMaster.newDevSession(context, "bw.db"); }// DaoSession daoSession = GreenDaoUtil.getDaoSession(this);// GreenDaoTableDao greenDaoTableDao = daoSession.getGreenDaoTableDao();// 通过greenDaoTableDao来进行数据库的操作 return GreenDaoUtil.daoSession; }} //项目build.gradle文件中添加classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' //app gradle 中 放到 dependencies 的外边 greendao { schemaVersion 3 //数据库版本号 daoPackage 'com.example.项目名.database' /