开发者

What is the best solution for saving user application data locally?

开发者 https://www.devze.com 2022-12-28 21:47 出处:网络
I am adding contact functionality to my program, and I want to save the contact list of each individual user, what is the best solution for this?I am new to XML and databases a开发者_如何学JAVAnd I do

I am adding contact functionality to my program, and I want to save the contact list of each individual user, what is the best solution for this? I am new to XML and databases a开发者_如何学JAVAnd I don't know which would be best or if there is a database solution that saves locally.


It depends on what platform you are targeting and the size and complexity of the data structures you want to persist. Obviously an open and easily readable format like XML or JSON or something else is preferable but for larger applications things like a SQLite database or even a custom save format might be appropriate.

So, the biggest things to consider are:

  • Support for your platform/language of choice
  • Importance of human-readability/hackability (could be desirable or very undesriable, and note that this also impacts the ability of third party developers to build applications that consume your saved data)
  • Size
  • Speed of accessing data (with a potential tradeoff of how much memory it would take to load it all into memory at once)

For some combinations of those a plain text file works, that gives near-universal language and platform support, human readable and editable, but could tend to get large for a fair amount of data. For larger applications, a SQLite database is the right answer though you have to check and make sure your platform/language supports it (most do), it means it can't be edited in a text editor (though users can use it with sqlite itself to modify), and it will be fairly compact and quite fast.


Well, it's all about the nature of your data:

  • CSV, XML, JSON if it's a configuration file
  • SQLite if is database oriented data and you need to perform search

What language are you using ?


There are several options, with different trade-offs. One is SQLite, a public domain relational database that stores the database in a single file. It has bindings for most languages.

EDIT: A good binding I've used for C# is System.Data.SQLite.

0

精彩评论

暂无评论...
验证码 换一张
取 消