开发者

Access to object from another activity

开发者 https://www.devze.com 2023-04-03 19:44 出处:网络
In my main Activity I have object with some data in it. I want to delete all this data through PreferenceActivity using method (wipe()) that does this job. How can I do it?

In my main Activity I have object with some data in it. I want to delete all this data through PreferenceActivity using method (wipe()) that does this job. How can I do it?

Access to object from another activity

Inside Preferences.java there is a OnPreferenceClickListener which, when activated, expected to use method in 开发者_Go百科object that I need to access.

Thanks in advance.


Just make this object as static.

Then you can access to this object by class name.

Activity.counters.wipe();

But, keeping data in activities is a bad practice in android development

0

精彩评论

暂无评论...
验证码 换一张
取 消