开发者

Android - How to store Address to DB

Looking to store android.location.Address to a SQLite database. I am using ORMLite to persist my objects. ORMLite can persist Serializable items (as a BLOB I believe) but I think the only way to get something Serializable from an Address is to write it into a Parcel. Then I took a look at Parcel here: http://developer.android.com/reference开发者_C百科/android/os/Parcel.html and it says it should not be used for general purpose Serialization mechanism. So I am just wondering what the best practice for doing this would be. I do not want to store the Address in contacts, strictly in my SQLite database. I am currently doing this with my own Address class (very simple) but would prefer to use the built in Android class for this.

thanks


The answer from the user list was to define a companion object that will be stored to the database and do the translation to/from the android.location.Address object by hand -- unfortunately. This will allow you to manager the storing of the various Address fields to the database without worrying about forwards and backwards compatibility with other Android versions.

Here's the discussion on the ormlite-user mailing list.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜