Android - 更新列表作为数据库更新

时间:2021-02-18 00:03:35

I'm looking for a method to update my ListView as my database is updating.

我正在寻找一种方法来更新我的ListView,因为我的数据库正在更新。

For instance when the app first loads, I asynchronously call my database and perform an insert of all the data (this takes up to 30seconds for all the API calls and inserts to run and is only performed on the first creation of the app). During which time I would like to be able to have the user navigate the app and once they get to a page that requires database information, I want the page to load with the current available data, and continue to update as more information is placed in the database.

例如,当应用程序首次加载时,我异步调用我的数据库并执行所有数据的插入(这需要最多30秒才能运行所有API调用和插入,并且仅在首次创建应用程序时执行)。在此期间,我希望能够让用户导航应用程序,一旦他们到达需要数据库信息的页面,我希望页面加载当前可用数据,并在更多信息放入时继续更新数据库。

At the same time, if a user is on a given page and the database gets updated in the background with additional information for that list, I would like the list to updated.

同时,如果用户在给定页面上并且数据库在后台更新并包含该列表的附加信息,我希望更新列表。

The async calls to the database are made in a separate class.

对数据库的异步调用是在单独的类中进行的。

Thanks, Dman

1 个解决方案

#1


0  

ContentProvider was able to do the trick. Thanks a lot.

ContentProvider能够做到这一点。非常感谢。

#1


0  

ContentProvider was able to do the trick. Thanks a lot.

ContentProvider能够做到这一点。非常感谢。