current position:Home>After the Android development database changes, the interface needs to be refreshed by clicking the button. I hope to refresh dynamically

After the Android development database changes, the interface needs to be refreshed by clicking the button. I hope to refresh dynamically

2022-01-27 03:35:17 CSDN Q & A

The phenomenon and background of the problem
// Course display     public void ShowCou(View view) throws ExecutionException, InterruptedException {        List<Course> List = dbCourse.selectAllCourses();        ListView lv = find(R.id.couList);        lv.setAdapter(new CouAdapter(List,this) );    }
Operation results and error reporting contents
My solution ideas and tried methods
What I want to achieve



Refer to the answer 1:

Send a message when the database changes , Write a message on the page that needs to be updated , When receiving the update message, call the code of the update interface




Refer to the answer 2:



Refer to the answer 3:



Refer to the answer 4:



Refer to the answer 5:

If you use sqlite Words
It is recommended to use room coordination livedata You can easily meet the above requirements
Please refer to my previous blog jetpack Series articles
I use #CSDN# This app Found a technical blog , My friends ask for the same 《Jetpack:Room Ultra detailed guidelines for the use of stepping pits !》, Let's have a look around https://blog.csdn.net/weixin_44235109/article/details/120252231?utm_source=app&app_version=4.20.0&code=app_1562916241&uLinkId=usr1mkqgl919blen
livedata guide
https://blog.csdn.net/weixin_44235109/article/details/120116205




Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270335156154.html

Random recommended