在android中保存该数据的最合适方法是啥
Posted
技术标签:
【中文标题】在android中保存该数据的最合适方法是啥【英文标题】:What is the most suitable way to save that data in android在android中保存该数据的最合适方法是什么 【发布时间】:2015-08-28 14:39:30 【问题描述】:我正在制作一个应用程序,它会询问用户他的教师、部门和年级,然后显示科目列表。
问题是保存主题的最佳方法是什么,以便于检索它们并将它们显示给用户。
我尝试了 XML,但它不起作用,现在我尝试了 JSON,但不确定它是否是存储此类数据的最佳方式?
回答:
正如所有人所说,最好的方法是将数据保存在 SQLite 数据库中。
这是我的 JSON 快照
"faculty_engineering":
"name": "Engineering",
"department_prep":
"name": "prep",
"grade_1":
"term_1":
"subjects": [
"Math",
"physics",
"English",
"Realisation",
"subject"
]
,
"term_2":
"subjects": [
"chemistry",
"Math",
"fekh",
"Geometry",
"Entag",
"Mechanics"
]
,
"department_systems_and_computer_engineering":
"name": "Systems and computer engineering",
"grade_1":
"term_1":
"subjects": [
"Programming",
"Electronics",
"Math",
"Circuits",
"Measure",
"English"
]
,
"term_2":
"subjects": [
"Algorithms",
"Electronics",
"Math",
"Fields",
"Religious subject"
]
,
"grade_2":
"term_1":
"subjects": [
"Math",
"Integrated circuits",
"Systems and signals",
"machines VHDL",
"Numerical Analysis",
"Object-oriented programming",
"Tests",
"Realisation subject"
]
,
"term_2":
"subjects": [
"Math",
"Logical circuits",
"Automatic Control",
"Electric machines",
"Religious subjects",
"Realisation subject"
]
,
"grade_3":
"term_1":
"subjects": [
"Math",
"Communications systems",
"Electronics",
"Religious subjects",
"Operating system",
"Digital Control",
"Tests ",
"Transition systems and mechanisms ",
"Power electric systems ",
"Realisation subject"
]
,
"term_2":
"subjects": [
"Databases",
"Microprocessors",
"Administration and engineering projects",
"Sensors of adapters",
"Religious subjects",
"Realisation subject"
]
,
"grade_4":
"term_1":
"subjects": [
"Special computer subject",
"Tests",
"Engineering programming",
"Intelligent Systems",
"Computer architecture",
"Interpreters",
"Advanced software",
"Realisation subject"
]
,
"term_2":
"subjects": [
"Algorithms",
"Advanced software",
"Computer architecture",
"Interpreters",
"Realisation subject"
]
,
"department_":
"name": "",
"grade_1":
"term_1":
"subjects": [
]
,
"term_2":
"subjects": [
]
,
"grade_2":
"term_1":
"subjects": [
]
,
"term_2":
"subjects": [
]
,
"grade_3":
"term_1":
"subjects": [
]
,
"term_2":
"subjects": [
]
,
"grade_4":
"term_1":
"subjects": [
]
,
"term_2":
"subjects": [
]
【问题讨论】:
我会将它们保存在数据库中。 如果您需要教程:vogella.com/tutorials/androidSQLite/article.html 我正在考虑将它们保存在 SQLite 数据库中,但我认为对于这种简单的情况来说它会过于复杂。 【参考方案1】:如果要查询的数据不在远程服务器上,则可以使用Android sqlite数据库来保存和获取数据。
【讨论】:
【参考方案2】:也许你应该使用 SQLite 数据库: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
JSON 和 XML 更可能用于传输数据,例如使用网络。
【讨论】:
【参考方案3】:您可以使用https://realm.io/,它兼容 Android 和 ios。 更简单快捷。
希望对你有帮助。
【讨论】:
【参考方案4】:如果您想要离线存储,请选择 SQLite。
如果您想要云存储,请选择 Google Firebase,因为它提供了良好的实现抽象、大量存储和同时连接。
【讨论】:
以上是关于在android中保存该数据的最合适方法是啥的主要内容,如果未能解决你的问题,请参考以下文章
从sql列中拆分数据并将其保存在sql存储过程中的另一个表中的最有效方法是啥[重复]