Is it better to store data in plist or Sqlite database? [duplicate]
Asked Answered
H

6

6

In my iPhone app, I have large amount of data i.e. around 1000 pages of text.

Where should I do to store them?

Should I use plist or Sqlite Database table?

Which of them would prove to be more efficient?

Please Help and Suggest.

Thanks in Advance.

Hagridden answered 25/11, 2010 at 11:34 Comment(1)
https://mcmap.net/q/1290915/-plist-or-sqliteWennerholn
B
9

For big amount of data, sqlite or coreData are better because all data are not load in memory to access to one.
With pList, entire file is read in memory. After, you can retain only data what you want, but it is not optimized.

Ballonet answered 25/11, 2010 at 11:38 Comment(1)
Thank you that makes it really easy to decide which to use. Ive never had it explained as clearly as, do you want all of the data loaded into memory at once or not.Sclera
A
5

Depends on how and for what you want to store the data:

Use SQLite if:

  1. Data needs to be accessed only partially
  2. Repeated updates
  3. Data itself is large in terms of bytes

Use plist otherwise!!

In your case, I would reccomend, using SQLite 3 or coredata.

Adscititious answered 26/11, 2010 at 11:16 Comment(0)
S
1

You should use a plist for storing configuration settings.

For what you're doing I'd use sqlite3 or core data storage.

Stockpile answered 25/11, 2010 at 11:39 Comment(0)
R
1

pList is really just an xml file so the advantages (such is both easily readable by human and computer) and disadvantages of xml (efficiency of storage/retrieval) apply.

While SQLite gives you the benefit of SQL obviously. For large data SQLite would be the better choice

Rubin answered 25/11, 2010 at 11:41 Comment(0)
L
1

What's important is the way you'll be accessing them. If it's something you access randomly or in small portions, you'd use a database like sqlite. If it's something you are using all of rougly at once, a plist is fine. As @Benoît mentioned, plists are loaded into memory completely. For something like a book you might also consider storing pages in separate files, thereby using the file system to manage access (depending on how you intend to use it of course).

Legault answered 25/11, 2010 at 11:43 Comment(0)
H
0

Property Lists

A plist is simply a list of nested key-value pairs which can contain common data types like Strings, Numbers, Arrays and Dictionaries.

Pros

  • Simple to understand.
  • Easy to work with.

Cons

Cannot run complex queries on them (at least not easily). You have to read the entire file into memory to get any data out of it and save the entire file to modify anything in it.

SQLite

Until CoreData came along, this was the popular way to read and write data in iPhone applications. If your a web developer, this ain’t nothing new.

Pros

  • Unlike plists, you don’t have to load the whole database up front. This makes SQLite more suitable for applications with lots of data.
  • Better than plists for slicing and dicing data.

Cons

Steeper learning curve than plists. Can get tedious to work with.

Core Data

Its new, its exciting, and its probably what most developers will use from here on out.

I have not spent enough time with CoreData to summarize it; check out the tutorials (below) to learn more about it.

Pros

  • Nearly all the benefits of SQLite with a lot less hassle (Apple does a lot of the dirty work for you).

  • As Apple’s preferred method it has a lot more official documentation and sample code (it seems the articles and sample code for the other two methods have mysteriously disappeared from Apple’s website).

Cons

  • Steeper learning curve than plists.
  • Killer: only works on iPhone OS >3.0. Its killer if your market consists largely of iPod Touch users (who have to pay for upgrades).
Haustorium answered 19/11, 2014 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.