如何释放或清除变量或对象的价值? [英] How to release or clear the value of variable or object?

查看:129
本文介绍了如何释放或清除变量或对象的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我所使用的一些变量,一个应用程序,我想释放或免费使用后,或在应用程序关闭时使用他们的存储空间。是否有这样做的任何进程?

I have an application in which I have used some variables and I want to release or free the memory space used by them after using them or on application close. Is there any process of doing this?

我用:

int x = Integer.parseInt(edt.getText().toString()) * Integer.parseInt(edt1.getText().toString());
String z = String.valueOf(x);

EDT - 支架对于EditText上,我已用于输入值。

edt - Stands For EditText which I have been used for entering the value.

输入值进入的EditText,每当我会切换到我的下一个活动页面,然后拿回我的previous页面上的EditText的值仍然可以在其之后。但是,我要清除的变量的值。

After entering the value into the EditText, whenever I'll switch to my next activity page and then get back on my previous page the value of EditText is still available on it. But I want to clear the value of the variable.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

正如你可以在的活动的生命周期图表当一个新的活动启动旧仅仅是暂停,所有值被保留。

As you can see on the Activity lifecycle graph when a new activity is started the old one is merely paused and all values are retained.

如果没有立即的需要存储器的系统的其余部分这不被破坏。

It is not destroyed if there's no immediate need for memory for the rest of the system.

我认为 EDT 是由专人(从不明显创建通过 findViewById 拍摄,而不是布局code)。所以,如果你想清除该值的EditText 切换回老活动时,你需要手工无论是在的onPause 或<$ C做$ C> onResume 。

I assume that edt is in the layout taken via findViewById and not created by hand (not apparent from the code). So if you want to clear value of that EditText when switching back to old activity you need to do it by hand either in onPause or onResume.

在应用程序关闭这些由Java虚拟机被释放。请记住,你离开最后一项活动后,立即您的应用程序可能无法被杀死。

On application close these will be released by Java VM. Keep in mind that your app might not be killed immediately after you leave last activity.

这篇关于如何释放或清除变量或对象的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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