Does OrmLite & greenDAO execute a request in the background thread and does it partially load the result into memory?

To avoid blocking the main / user interface stream, the Android API provides Loaderaccess to the database. To save memory (RAM), the API does not load entire lines (result) into memory, so that we can have ListViewcontaining so many elements without memory.

Do OrmLite and greenDAO provide both of these features? If not, is there any approach for doing asynchronous request and partial loading and replacing to fill huge data in ListView?

+4
source share
2 answers

I do not think that ORM frameworks provide the ability to load only parts of a string.

With greendao, you can use listLazy()on yours Queryto load objects lazily from the database. This provides excellent performance by prefetching all objects.

I know that greendao also provides some way to asynchronously load objects using AsyncSession. But I do not currently know how this will be used.

Usually, all CRUD operations in greendao occur in the same thread that caused the update, etc.

I have not used OrmLite yet, so I have no information about this.

0
source

OrmLite, greenDAO. , db. SQLITE.

NoteActivity greenDAO: https://github.com/greenrobot/greenDAO/blob/master/DaoExample/src/main/java/de/greenrobot/daoexample/NoteActivity.java

onCreate() , :

DevOpenHelper helper = DaoMaster.DevOpenHelper(, "db_name", null);
SQLiteDatabase db = helper.getWritableDatabase();
DaoMaster daoMaster = DaoMaster (db);
DaoSession daoSession = daoMaster.newSession(); ObjectDao objectDao = daoSession.getObjectDao();
[..]
cursor = db.query(objectDao.getTablename(), objectDao.getAllColumns(), null, null, null, null, null);

, . , , . ( ):

  • db/daoSession . .
  • loadInBackground(). db- . .
0

Source: https://habr.com/ru/post/1543374/


All Articles