[英]Reload database value after back button
On my homescreen I am getting a certain value out of my DB (item out table where a field active=1): 在我的主屏幕上,我从我的数据库中获得了一定的值(项目输出表中的字段有效= 1):
String s2 = "Logged in as " + myDbHelper.getActivePlayer();
bPlayQuiz.setText(s2);
When I click to my settings activity, change the player, another player gets field active=1. 当我点击我的设置活动时,更改播放器,另一个玩家获得字段激活= 1。 So when I hit the back button, the first value is still there... Any idea how to code this that it will refresh when I come back on my homescreen?
因此,当我点击后退按钮时,第一个值仍然存在...任何想法如何编码,当我回到主屏幕时它会刷新?
You can always reload the field in the onResume
, which is called whenever the activity regains focus: 您始终可以在
onResume
重新加载字段,只要活动重新获得焦点,就会调用该字段:
@Override
public void onResume()
{
super.onResume();
String s2 = "Logged in as " + myDbHelper.getActivePlayer();
bPlayQuiz.setText(s2);
}
There's more information about the resume part of the lifecycle here . 有一个关于生命周期的恢复部分的详细信息在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.