Currently, I have a flutter app using Spring Boot Framework with MongoDB. I want to add Offline functionality to the application.
App Functionality:
User fills various forms(personal details, family member details, etc).
Use Case: When the user fills the Personal Details Form fields like 'name', 'dob' are filled manually and location (selected using the dropdown(GET APIs)).
The internet connection might be gone while filling these forms.
How can I make the application offline ready?
One way that I thought of is storing all the data using any local database like SQLite but there can more than 10 Forms so it can be difficult for maintaining a lot of data. Moreover, how the data will sync with Backend?
Questions:
How to store data?
How to sync store data with Backend when the app comes Online?
Is there any other better approach to achieve this task?
Related
I have a requirement to store data locally to use within a Flutter mobile application. This stored data will be used for when the device is offline and will need to be updated, whilst offline.
On initial login of the application, data must be pulled from a REST API and stored locally to be displayed within the app.
Does anyone have any pointers as to what is the best method for this? I've looked at Sqflite but i can't seem to see any tutorials or documentation on setting this up using an API to 'fill' the data initially.
Any advice would be appreciated.
There are many ways to go about this.
One option is simply using dio, which has caching support built in.
Or, you could use something like hive or SharedPreferences along with http to to persist the data yourself (depending on what level of control you want/need).
You could also encapsulate the data in a state management solution like riverpod (specifically a FutureProvider in this case) which will soon have offline persistence support.
If building an application from scratch, I'd recommend the riverpod route (and it will soon have that offline persistence support).
How to sync data between MySQL server and Sqflite in flutter? I just want to integrate the offline mode in my flutter app...
Is there any library for this?
Unfortunately, there is no library for this. But, it should be pretty straight forward to implement. Just follow these 3 points:
1) Create a function for initial upload of data on SQFLite on from MySQL database when for eg: when a user enables offline mode, or logins for the first time, etc. whatever is relevant to your use case.
2) Then you have to have another function which when the user is online, checks if SQFLite data is in sync with MySQL, if not it updates SQFLite database (This step is unnecessary if the MySql database for the user can only be modified by the user, in which case just the 3rd point is sufficient)
3) Another function is required where when the user changes MySQL data(read, updated, deletes), SQFLite data is updated by recent MySQL data.
If you know basic querying of MySQL and SQFlite (which is quite similar) and are familiar with deserializing data, this should be easy to implement.
I already have a django application and am trying to develop an iPhone app. I'm using mysql as the database for the django app.
Here are some questions I was having :
Is it necessary to use Core Data for anything?
Can I create a rest api to interact with the mysql database?
If so, would there be any advantage, at any place or reason, to use Core Data in addition to mysql. For example, for an app like Pinterest, Tumblr, Facebook, etc. are they using Core Data at all? If so, why and how?
Core Data is one way to give you a local database on the phone. With only MySQL on the server, the app cannot access any data when offline. Even in an online-only app, a local cache of some of the data can be useful to speed things up.
Similar to Django,where it has and database-abstraction API that lets you create, retrieve, update and delete objects, iOS has an CoreData. What under-lies is still SQL. From the django end, you need to create an api that returns the class of objects or something. On the iOS side, you have to call this api and parse the data and save it locally using CoreData.
Hope this helps..
I am a bit of a newbie when i comes to iphone dev, but was wondering the best way to retrieve informations form a MySQL database.
I have a load of information via a website all stored on a database which changes daily and wanted to build an app that pulled in the information depending on parameters.
What would be the best way to achieve this? Can you grab info from MySQL or would a XML feed be a safer bet?
Build RESTful web services that hide your MySQL database and then consume them from your iPhone app.
I'm looking to write an iPhone app that populates a UITable with information from a field in a database that is stored online, and when selected shows more information from the database.
For example, a list of names that when tapped will show a bio for the person, some basic stats, and a picture.
OR
Is it possible to use CoreData, and have it populate itself on start up with the information from the online mySQL database? This would give the best of both worlds - the uptodate nature of the web and the offline access...
I would suggest using something like PHP to talk to the MySQL database and creating your app to talk to the PHP via a web address. Bit of a security risk to have an app talk directly with a database due to the database not being behind a firewall and your database details being stored in the program and being sent across non authed means.