Can Sqlite work fully offline?

Asked

Viewed 1,003 times

5

I need to save my alarms so that after the device is restarted they are put back into operation.

The problem is that I get all of them through my database on mysql.

What made me think that maybe it would be a good idea to store in an offline database and then be able to put the schedules back to work.

Then two questions arose:

  1. Sqlite can work fully offline?

  2. If yes, if the user clears the cache or the data. What happens to that database?

  • 2

    Sqlite is almost always to work offline. Online gives, but is exception.

2 answers

5

You can create the database(sqlite), put it in the Assets folder of your project and use the offline database quietly.

For example, you can use DB Browser http://sqlitebrowser.org to create and fill . bd, and in addition, you can also use this library here https://github.com/jgilfelt/android-sqlite-asset-helper to help you read the bank.

But why don’t you simply use an XML or JSON file to store this data? It would be no less laborious?

  • How do I create a Json so it can be accessed offline is really a better solution and json is something I can work on if I can explain would be grateful , remembering even if the user cleans the data json has to continue with the data saved

  • XML or JSON file are more useful for network data traffic, not as database usage.

  • 1

    User preferences, for example, are saved in a .XML. http://codetheory.in/saving-user-settings-with-android-preferences/, worth a read.

5


  1. Sqlite can work fully offline?

Sqlite is a library in c language which implements a built-in SQL database. Programs that use the Sqlite library can have access to SQL database without running a separate DBMS process.

Sqlite is not a client library used to connect to a large database server, but the server itself. The Sqlite library reads and writes directly to and from the database file on disk, ie it works totally offline.

  1. If yes, if the user clears the cache or the data. What happens to that database?

Data saved in the database SQLite are not cleaned (deleted), by the memory manager, only procedures or routines that access the data can make this change.

See also:

Sqlite-Sync is a structure for synchronizing data between an Sqlite database and an MS SQL / Mysql database. With this framework your application can work completely offline (Airplane Mode), then run a bidirectional automatic synchronization when an internet connection becomes available.

Here has a project with this architecture as an example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.