在Android中插入新数据后如何在ListView中获取数据库数据 [英] How to get database data in listview after insert new data in android

查看:484
本文介绍了在Android中插入新数据后如何在ListView中获取数据库数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我在SQLITE数据库中有一个疾病表,其中包含疾病列表.当我进入新活动时,我将从疾病表中获取数据并将其加载到列表视图中.现在,在列表视图页面中.im在疾病表中添加新疾病.插入数据后,如何刷新列表窗口. 有任何建议吗?

Here's the scenario like, I have a disease table in SQLITE database it contains a list of disease. While i enter into the new activity,i will get the datas from disease table and load it in listview. Now,in listview page..im adding new disease in disease table. After insert data,how to refresh the listvew. Any Suggestions??

推荐答案

您必须通知适配器有关数据的更改,以便刷新列表视图.根据您的情况,在插入后调用cursorAdapter.notifyDataSetChanged()之类的东西.

You have to notify the adapter for changes on data so it will refresh the listview. In your case, call something like cursorAdapter.notifyDataSetChanged() after doing the insertion.

这篇关于在Android中插入新数据后如何在ListView中获取数据库数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆