JustWeEngine v1.04 Release Notes

Release Date: 2016-03-19 // over 5 years ago
  • 11.SQLite数据库

    SQLite使用了IOC框架。

    11.1创建表

    新建的创建表需要继承Node并且写出注解类。

    // 表名@TableName(tableName = "lfkdsk") public class User extends Node { // 主键自增 INTEGER型@LabelName(autoincrement = true, type = LabelName.Type.INTEGER, columnName = "name", generatedId = true) private int name; // TEXT型 栏名为user\[email protected](type = LabelName.Type.TEXT, columnName = "user\_name") private String user\_name; // 自增主键所以只需要提供其他信息public User(String user\_name) { super(user\_name); this.user\_name = user\_name; } public User(int name, String user\_name) { super(name, user\_name); this.name = name; this.user\_name = user\_name; } public int getName() { return name; } public void setName(int name) { this.name = name; } public String getUser\_name() { return user\_name; } public void setUser\_name(String user\_name) { this.user\_name = user\_name; } }
    
    // 通过这种方式获取数据库 表名private DataBase dataBase = DataBase.initAndOpen("user", User.class);
    

    11.2增删查改

    // add database.insert(User user); // find database.get(int position); // delete database.delete(int position); // update database.update(User user); ...