【问题标题】:Where to store json datas instead of using sqlite in android?在哪里存储json数据而不是在android中使用sqlite?
【发布时间】:2013-02-19 07:15:51
【问题描述】:

我正在访问来自 json 的数据,将来自 json 的数据存储在 sqlite 中,然后检索它并在屏幕上显示它们。这个过程需要很长时间。哪个是减少时间消耗而不是从 sqlite 存储和检索数据的更好方法?谁能帮我解决这个问题?

【问题讨论】:

  • 你可以创建.json文件并访问它

标签: android json sqlite


【解决方案1】:

您可以将 JSON 作为纯文本存储在文件中。

放置它们的好地方是应用程序的缓存目录。

https://developer.android.com/reference/android/content/Context.html#getExternalCacheDir() https://developer.android.com/reference/android/content/Context.html#getCacheDir()

【讨论】:

    【解决方案2】:

    您可以将 JSON 数据存储在文件或共享首选项中。检查Saving data in android training

    【讨论】:

      【解决方案3】:

      我也使用文件系统来存储json。它可以更容易调试,因为您可以让 json.tostrong 方法缩进 json 哟使使用 android 文件浏览器更容易阅读。

      我创建了一个接受并返回 json 的文件系统类,因此应用程序只将文件系统视为 json 存储。

      【讨论】:

        猜你喜欢
        • 2013-03-25
        • 2010-12-03
        • 1970-01-01
        • 1970-01-01
        • 2017-11-04
        • 2019-08-27
        • 1970-01-01
        • 2017-10-24
        • 1970-01-01
        相关资源
        最近更新 更多