Search code examples
androidandroid-contentprovidergreendao

Green Dao, ContentProvider generation


how to use this template GreenDao generator to generate ContentProvider class: https://github.com/greenrobot/greenDAO/blob/master/DaoGenerator/src-template/content-provider.ftl

And what it means this parameters:

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

And how i can implement THIS:

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


Solution

  • public static final String BASE_PATH = "${contentProvider.basePath}"; - it is TABLE NAME

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

    - it is Primary Column Name, for example:

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

    I do it ContentProvider DAO and it work fine!