当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Async delete and update items in database

问题描述:

I use CursorLoader to show data in my recycler view. I also need provide delete and update item feature. What is the best solution to delete and update items in database? Now I use simple AsyncTask.

Update

The best solution is to use AsyncQueryHandler?

网友答案:

According to the guidelines it depends. If you want your app to sync with the server after a certain period of time(2-24hrs), use SyncAdapter. If you dont need to sync, use service or intentservice.

AsyncTask not the best option, the latest "efficient" apps nolonger use it

The main problem with the asyncTask is that its lifetime is tied to the activity. So if your app is doing a background process like inserting new data into the DB and the activity closes or the user presses the back button, the process may be terminated before completion

分享给朋友:
您可能感兴趣的文章:
随机阅读: