开发者

How to save parsed data in android?

开发者 https://www.devze.com 2023-04-05 04:41 出处:网络
I am creating an android application in which I am parsing so much XML data (XML data comes from a server) which contains Strings and image url\'s also.I need to use this data in many part of applicat

I am creating an android application in which I am parsing so much XML data (XML data comes from a server) which contains Strings and image url's also.I need to use this data in many part of application. So for saving all these data I have used ArrayList and HashMap.I have declared ArrayList's and HashMap's variables in a single class as public static variables so I can access this data through a single class whenever I need.

And for images I have created ArrayList and placed in same single class same as other data(public static).Once I download a i开发者_开发百科mage through image url's I save those image drawables to these ArrayList variables so whenever I need any image again so I use these variables to get it.

Now my doubt is whether this approach is right or not. Please suggest me the right way.

Thank you


You should actually take a look at: http://developer.android.com/guide/topics/data/data-storage.html

It all depends on how you use the data, does it need to be updated all the time when the user opens the app you could take a look at this answer: How to declare global variables in Android? where you declare a global application and have the variables there.

Otherwise I would actually advice to use an sqlite database. http://developer.android.com/guide/topics/data/data-storage.html#db One good example is here: http://www.vogella.de/articles/AndroidSQLite/article.html

0

精彩评论

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