简体   繁体   中英

What is the most suitable way to save that data in android

I'm making an app that will ask the user for his faculty, department and grade and then show List of subjects.

the question is what is the best way to save subjects that it can be easy to retrieve them and display them to the user.

I tried XML but it doesn't work and now I'm tried JSON but not sure if it the best way to store that kind of data?

ANSWER:

as all people say the best way is to save the data in SQLite dataBase.

here is a snap of my 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": [
          ]
        }
      }
    }
  }
}

如果要查询的数据不在远程服务器上,则可以使用Android sqlite数据库保存和获取数据。

Maybe you should use a SQLite database : https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

JSON and XML are more likely to be used to transfer data, using network for instance.

You can use https://realm.io/ that it's compatible between Android and iOS. It's more simply and quickly.

Hope it helps.

If you want offline storage then go for SQLite.

If you want cloud storage then go for Google Firebase as it provides good abstraction for implementation, fair amount of storage and simultaneous connections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM