Which is better for simple data storage: SQLite or Shared Preference?

Asked 2 years ago, Updated 2 years ago, 23 views

I want to receive data from the application and save it inside.

For example, if you get a string like "Apple\nRed\n123" or "Banana\nYellow\n456", you separate the words separated by\n and save them, and then you show the apples and bananas in the list and show them the properties when you select them.

You want to use SQLite or Sharedpreference as a tool to save. For Shared, we know that it is a tool for storing simple application settings. But when I used it, it was simple. So in the case of information that I'm going to store, I think shared is more convenient than SQL because it's simple information.

What do you think, developers? Is it better to use SQL for purpose or simply use Shared Preference, even if it's more complicated?

android

2022-09-22 20:39

1 Answers

SQLite and ShedPreference are the same in terms of storing data in a file, but their actual uses are different. SQLite has a large amount of data to store, and is used to quickly query stored data (according to conditions), and to store, modify, and delete structured data. On the other hand, ShedPreference stores simple information in the form of a key-value and uses it to inquire.

Compare if the data you want to save is data such as address book, text, and if so, if not in SQLite, I think it would be better to save it in ShedPreference.


2022-09-22 20:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.