2015-04-04 38 views
2

我在我的项目中使用了GreenDao库,当我想从DB读取数据时出现问题,它给我android.database.sqlite.SQLiteException: no such table无法生成小写的greenDao实体

我知道发生这种情况的原因。因为当我生成这个Scheme并添加这样的实体时:addEntity("userX")生成的表格是USER_X

的问题是,我从资产加载数据库和表名是userX,不USER_X。我在greendao doc中看到:For example, a property called “creationDate” will become a database column “CREATION_DATE”.

我的问题是我该如何改变这些默认值? 我已经在文档中搜索解决方案,但我还没有找到任何解决方案。有没有解决我的问题?

感谢

回答

2

我从来没有使用过,但看着this documentationthis source code,它使用实体

Entity e = addEntity("userX"); 
e.setTableName("userX"); 

这种方法似乎是可能的,这对于性能

e.addDateProperty("creationDate").columnName("creationDate");