English 中文(简体)
储存JSON在一片泥土中?
原标题:Store JSON in an sqlite field?

I m writing an application that communicates with a web API, which responds with JSON. Currently, I m translating the JSON objects to Java objects using gson (which is awesome, by the way).

Now, I want to store some of these objects in an SQLite database. However, they have lots of properties that would never be used in queries (i.e. I won t be ORDERing, WHEREing, or anything like that with those properties), so I feel it s unnecessary to create columns for all of them. What I m thinking of doing is:

  • Only have columns for the essential data that will be used when querying the database
  • Have one TEXT or BLOB column (which one do you recommend?) that stores the actual JSON, so I can recreate my Java object from it and access all the data.

This would both make my life easier and streamline my code (I would not have to write very different code when dealing with data from the API vs. data from the database).

然而,尽管我看不出底部,但我感觉到底鱼。

如果我使用这一技术,你会遇到什么样的麻烦?

最佳回答

我要谈的主要事情是依靠所储存/受伤害的JSON的结构来有效,因为它完全脱离了数据库。 你们不能对可能的问题采取预防措施,但如果是神学家以 trip子的方式run倒或以其他方式破坏他们,那么你就会再 missing掉整个物体,而不只是一个无效或拖.的财产。 如果这种风险是可以接受的,则可能是一种合理的技术。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签