开发者

how much space needed to Store SharedPreference in Android?

I have one Application which has more then 5 Activity I want to know how much space is needed to store 10 different values to SharedPreference. or I have to user Sqlitequery ?

Simple in One Activity I have 4 Field like FirstName,LastName, Age, City when user Click on th button then new Activity is called and in this activity Full Information is Display, so I can do that in two way. First Way I Store all the Info开发者_开发知识库rmation in the SharedPreference and in Second Activity I get this Stored Values and another way is i only store record id and store it in intent.putextra and get it to another activity and Fire Sqlite Query. so I want to know which one is best for Application .(As per Memory Uses and Speed )


If you do not need persistent storage then you can simply pass the data using intents from one activity to another or maybe even keep some static variables in a separate class say Const.java

If you need persistent storage and if your data is limited, I would always recommend using SP over SQLite which should be used for relational data. DB operations take more time and can hit performance besides there is always chance of DB getting corrupted.


Sqllite is a really good solution if you want to be able to add easily more preferences. It's a bit heavy to set-up but really powerfull.

http://developer.android.com/guide/topics/data/data-storage.html

For me, database is for storing data, and sharedpreference just app config.


Shared preferenses apereas to be the choise here, it is very good to store simple settings and very fast and flexible. A database would IMO be overkill here :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜