Android的SQLite的读取和写入 [英] Android sqlite read and write

查看:454
本文介绍了Android的SQLite的读取和写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录后tabhost填写的表格。我已成立了一个线程来填写表格。同时,我在那里点击我已经设置了另一个线程从同一个表中读取数据,并填写列表视图中的适配器选项卡上。

I am filling a table on tabhost after login. I have set up a thread to fill in the table. Meanwhile I click on the tab where I have set up another thread to read the data from the same table and fill the adapter for the list view.

我的问题是,填补上tabhost表中的线程需要一定的时间,同时,如果我在选项卡上单击显示,从表中的数据,也没有任何因为适配器的发现数据是空的。

My problem is that the thread which fills the table on tabhost takes some time and meanwhile if I click on the tab to show the data from table it shows no data found because of the adapter being empty.

如何解决此问题?是不是像生产者/消费者可使用解决等待()通知()

How to solve this? Is it something like producer/consumer which can be solved using wait() and notify()?

推荐答案

最简单的(又名hackiest)的方式我能想象吗?

Easiest (aka hackiest) way I can imagine?

在您的主要活动创建一个静态布尔值设置为false。有后台线程它设置为true,一旦更新的数据。其他活动可以检查布尔是假的,并送你回去主要还是提出了一个烤面包,说明该数据仍在加载。

Create a static boolean set to false in your main activity. Have the background thread set it to true once it has updated the data. The other activity can check if the boolean is false and send you back to main or put up a toast stating the data is still loading.

或者只是如果没有数据发现,简单地说了,你是装敬酒。你可以有一个定时器运行刷新页面,直到找到数据。

Or just if no data is found, simply put up a toast that you are loading. You can have a timer running to refresh the page until data is found.

这篇关于Android的SQLite的读取和写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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