1. 程式人生 > >Android greenDAO 使用案例解析

Android greenDAO 使用案例解析

//所以你自己要在src同一級目錄下新建一個src-gen資料夾(資料夾名字是“src-gen”,不是“gen”).
        new DaoGenerator().generateAll(schema, "src-gen");
    }   
  
    private static void addUser(Schema schema){
    Entity note=schema.addEntity("UserEntity");//UserEntity相當於表的類名,通過UserEntity就可以訪問這個表的屬性了
    note.addIdProperty().autoincrement();//新增自增的ID屬性
    note.addStringProperty("name").notNull();//新增字串型別的name屬性,且欄位不可為空
    note.addIntProperty("age").notNull();//新增Int型別的age屬性,且欄位不可為空

    note.addBooleanProperty("sex").notNull();//添加布爾型別的sex屬性,true代表男,false代表女,且欄位不可為空
    }
        
}