android - GreenDAO的数据库操作需要在子线程完成吗?
怪我咯
怪我咯 2017-04-17 17:37:19
0
3
1668

刚开始使用GreenDao,不是很熟悉。还有一个就是,更新数据之后要怎么才能立即刷新数据呢?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
巴扎黑

GreenDao provides a unified interface class AsyncSession for asynchronous operations, which provides all the asynchronous operation methods you need.
You can get an AsyncSession instance by calling DaoSession.startAsyncSession().

DBManager.getInstance().getDaoSession().startAsyncSession().runInTx(new Runnable() {

            @Override
            public void run() {
                //DELETE
                //DELETE
                //UPDATE

            }
        });

You can also open a thread yourself.

Batch database operations can use GreenDao transactions.

大家讲道理

All time-consuming operations in Android should be placed in child threads. Reading and writing databases are time-consuming operations.

After data acquisition, use the corresponding adapter to refresh it.

PHPzhong

Many operations of the realm database can be done on the main thread

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template