I want to know is Database more efficient or just a normal json file if it has many items, in android device.
No, Sqlite will read data for hard disk by paging. The Sqlite document said: "In order to return data from the database to the user, for example as the results of a SELECT query, SQLite must at some point read data from the database file. Usually, data is read from the database file in aligned blocks of page-size bytes. "
Link: https://www.sqlite.org/fileio.html
There is an option when "connecting" to an SQLite database of using memory
instead of filesystem
as storage.
But it is used only when creating new databases so the "new" in memory database will be empty. This is useful when you want to take advantage of SQL like indexing and querying on a large set of data.
Unfortunately copy from filesystem into memory (or vice-versa) is not a feature in SQLite. It's a design choice because the SQLite file must be locked by your (or others) for concurrency control.
Typically a DSN
to connect to an SQLite database would look like this 'sqlite:/path/to/file.sqlite'
. And access control to the database is given by access filesystem rights. In the case of in memory databases the DSN
will look like this 'sqlite::memory'
.