管理全局对象或列表 [英] manage global object or list
问题描述
我读过很多关于单身人士如何在android中易受攻击的博客.所以我的问题是如何在应用程序中维护这样的全局对象或列表.我知道共享首选项是一种方法,但是有什么方法可以有效地维护这样的对象或列表.any帮助会更有帮助.
I have read many blogs about how singleton are vulnerable in android.so my question is how to maintain such global objects or list in application.i know shared preference is one way but is there any way to maintain such objects or list efficiently.any help will be more helpful.
推荐答案
使用sharedPreferences,Sqlite数据库来管理您的对象,单例不是很好,但是静态变量更难以维护,并且将使测试更加困难,如果数据不是很大,则可以使用共享"首选项来维护全局状态,如果数据量很大,则建议使用sqlite.
use sharedPreferences, Sqlite database to manage your objects, singletons are not very good, but static variables are more hard to maintain and will make testing the cide more tough, you can use Shared preferences to maintain a global state if the data is not very large, if there is large amount of data then use of sqlite is recommended.
共享首选项非常易于使用,如果您在使用sqlite时遇到问题,尽管可以为Android使用orm库
这是一个链接: http://greenrobot.org/greendao/
Shared preferences are extremely easy to use, if you have problem using sqlite though you can use orm libraries for android
here's a link to one: http://greenrobot.org/greendao/
这篇关于管理全局对象或列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!