Green Dao,ContentProvider代

时间:2013-11-27 16:23:34

标签: android android-contentprovider greendao

如何使用此模板GreenDao生成器生成ContentProvider类: https://github.com/greenrobot/greenDAO/blob/master/DaoGenerator/src-template/content-provider.ftl

这个参数意味着什么:

public static final String BASE_PATH = "${contentProvider.basePath}";

https://github.com/greenrobot/greenDAO/blob/master/DaoGenerator/src-template/content-provider.ftl#L28

private static final String PK = ${entity.classNameDao}.Properties.${entity.pkProperty.propertyName?cap_first}.columnName;

https://github.com/greenrobot/greenDAO/blob/master/DaoGenerator/src-template/content-provider.ftl#L36

我如何实现这个:

<#if contentProvider.isReadOnly()> https://github.com/greenrobot/greenDAO/blob/master/DaoGenerator/src-template/content-provider.ftl#L80

2 个答案:

答案 0 :(得分:1)

现在每个实体都有自己的ContentProvider,只需调用实体的addContentProvider即可。

例如:

        Entity clientServer = schema.addEntity("ClientServer");
        clientServer.addIdProperty();
        clientServer.addIntProperty("tedadMorajeat");
        clientServer.addLongProperty("clientId");
        clientServer.addLongProperty("serverId");           
        clientServer.addContentProvider();

答案 1 :(得分:0)

public static final String BASE_PATH = "${contentProvider.basePath}"; - 它是TABLE NAME

private static final String PK = ${entity.classNameDao}.Properties.${entity.pkProperty.propertyName?cap_first}.columnName; 

- 它是主要列名,例如:

private static final String PK = MYTABLENAMEDao.Properties.Id.columnName;

我做了ContentProvider DAO,它工作正常!