美文网首页
greendao的使用增删改查<3>

greendao的使用增删改查<3>

作者: 天空在微笑 | 来源:发表于2017-11-21 23:29 被阅读13次

greendao的增删改查

public class MainActivity extends AppCompatActivity {
    private NoteDao noteDao;
    private Note note;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DaoSession daoSession = ((AppApplication) getApplication()).getDaoSession();
        noteDao = daoSession.getNoteDao();

        addNote();
        queryNote();
        updateNote();
        deleteNote();
    }

    public void addNote() {
        note = new Note();
        note.setText("this is test note!");
        note.setComment("this is comment");
        noteDao.insert(note);
        Log.d("DaoExample", "Inserted new note, ID: " + note.getId());
    }

    public void deleteNote() {
        noteDao.delete(note);
    }

    public void updateNote() {
        note.setText("this is after modify note!");
        noteDao.update(note);
    }

    public void queryNote() {
       List<Note> noteList = noteDao.queryBuilder().where(NoteDao.Properties.Text.eq("this is after modify note!")).build().list();
    }

}

使用stetho查看数据库
android调试桥工具stetho的使用

相关文章

  • greendao的使用增删改查<3>

    greendao的增删改查 使用stetho查看数据库android调试桥工具stetho的使用

  • GreenDao使用(增删改查)

    前言: Greendao是一款用于数据库创建与管理的框架,由于原生SQLite语言比较复杂繁琐,使得不少程序员不得...

  • Swift中CoreData的基本用法

    前几天看了一下CoreData的增删改查,于是试着在demo里面加进去使用 增 删 改 查

  • mysql的插入语句

    MySQL增删改查之增insert、replace

  • GreenDao笔记

    GreenDao官方文档比较详细,通读一遍基本可以上手使用.下面是一些使用记录. 基本功能 除了基本的增删改查,G...

  • MYSQL数据库的增删改查

    MYSQL数据库的增删改查 一.对于库的增删改查 增create database 库名称;create data...

  • 关于python的list的增查删改

    说到增查删改,想起了数据库,我们在关系型数据库当中就会对表进行增查删改。 在python当中我们也可以对list进...

  • 0812 A

    mongodb 增删改查 增: db.createCollection("name", {options:numb...

  • 增删改

    对于表中的操作,就是增删改查,查内容较多,这里先说增删改。 1.增(insert或者load) 即插入数据,多行插...

  • 【Android】GreenDao增删改查(三)

    (1)插入 常用API 插入 (2)查询 Dao查询常用方法 Dao查询 QueryBuilder查询常用方法 返...

网友评论

      本文标题:greendao的使用增删改查<3>

      本文链接:https://www.haomeiwen.com/subject/swvgvxtx.html