Integrating seed DB with Parse local datastore - android

We are developing an app for both iOS and Android. In both the platforms we are not using the native DB (i.e., in iOS core data and in Android sqlLite). Instead of native DB we are using Parse local datastore.
In Parse we are going to keep huge amounts of static content. When user’s install the app for the first time, we don’t want all the contents from Parse to be downloaded. Because it may take some time to download the contents from DB.
So we have decided to use the seed database concept. This will not take much time. It will be a good user experience.
Our question is how we can use the seed DB concept with the Parse local datastore. Because it is not possible to identify where Parse is storing the local datastore in iOS/Android. Also, we hope when the app installs for the first time from the store, Parse will create a new local datastore. So how shall we sync the huge contents initially to the Parse local datastore.
Can anyone give a suggestion for integrating seed DB with Parse local datastore.

Your best bet here is to seed your app with a Core Data database, then synchronize the Core Data to Parse incrementally. Essentially, you would start with a Core Data database on the initial load and slowly transition to using Parse directly, or alternatively, you could use the Core Data as your primary connection and have it sync with parse as needed, like so:
UI/Local Controller <==> Core Data <==> Parse.com
This is too big a question to give a full code example, but I can point you in the right direction with a solid framework build specifically to do this job:
https://github.com/8020world/FTASync

Related

How to best handle data models in an an Android App?

I have a college project where the idea is to allow gym-goers to record their progress/evolution in several machines/exercises (e.g. first week I ran 6km in the treadmill in 15 minutos; second week I ran 6.5km, and so forth). I want the user to be able to create an activity plan by selecting several machines/exercises from a list, and each machine/exercise has properties (such as repetitions, muscle groups trained, time, weight, distance, etc).
So, my question is: what is the best way to store the different types of machines/exercises on the apk? Is it to create models for each generic type and load them from a local JSON? Define each exercise outside the app and connect it to a database and have the app fetch the list to the user?
In a prior project I created a Truth or Dare game where the questions (truths or dares) where loaded from a local JSON and turned using a factory to actual questions (using a Question model) to display in-game, but I never found out if that's the best/correct approach.
P.S.: there exists both the possibility that the App is solely local OR that it will be connected to a server + db. Unfortunately, due to the nature of the project I cannot give a concrete answer to this question, but would instead appreciate an answer to both cases...
Thanks in advance!
Using apk's local storage for data storage/retrieval
In such case you can either use JSON for storage/retrieval or android's SQLiteDatabase . If you use SQLiteDatabase for storage your app will contain db file which is a small database embedded in apk
If your data contains multiple entities related to each other then you have to go for SQLiteDatabase as using a plane JSON in such case would not be simple
Using remote storage for data storage/retrieval in apk
In this case you can setup database server in remote machine for your app.
Or
You can use Firebase
It depends what type of app you are making, if user doesn't have to update its exercise progress to remote machine then local SQLiteDatabase would be sufficient in your case

How can I create a sqlite database file to be returned by a webservice

I want to create a sqlite database file in a web service, so I dont have to read a json in the android device and wait for it to read the json, convert it to an object and then insert it to the database.
When the json is huge, with a lot of data, that process its to long for be waiting in an android device.
I would like to generate the database file of sqlite in the webservice, so that, instead of returning the json, it returns the sqlite database, and in android, I just need to save the database, so that, it is ready to use.
That would save a lot of time!
SQLite have libraries for almost any kind of server side language.
SQLite db is just a file so after is created you shall compress is in a zip and use volley library to dl the file over http.
Decompress the zip and connect to it.
I have no idea about which kind of data and which amount you need to transfer but if the data is organised properly the processing should be so long. Also you have to take in consideration that using JSON you can "ask" to receive only updates (delta) and this is something that is not possible if you download all the db each time.
Update: for this kind a data I would go to a different approach. Use docs from google publishing api to upload every specific period of time the db in an extension pack for your app. so most of the dl'ing process is even before the "install" on the device itself. When the app is first running will contact your server and get the latest updates since the db was created (I suppose that even that is a week you are talking about less than a hundred rows)...

How many objects can be stored or cached in Parse Local Data Storage?

I have my application with Parse.com as a backend. To reduce performance issues I am reducing network calls rather I have enabled Local Datastore for Parse.
However I want to know how many objects are pinned in Local Data Store. Can I store whatever numbers of objects I want.
One more thing to unpin all objects from local datastore. I am going to write Service in Android which will run after one day clear local datastore.
I used ParseObject.unpinAllInBackground();
but it doesnt work please help.

Intel XDK: Connecting your mobile app to a database

I am currently developing an application which if I don't have a database, the application after building will be heavy. How do I connect the application to a database, either local or remote?
Thanks in advance.
You can use one of the following methods for using database:
1- Using HTML5 client side databases. HTML5 provides four different types of Storage of data on a local client's machine. They are
Local Storage.
Web SQL Storage.
Session Storage
Indexed DB
It depends on your demands you can use one of them. If you need a persistent database for saving values less than 5 Mb, I recommend you LocalStorage as implementation of that is very easy. The data you saved in HTML5 localstorage will not be deleted even in case of phone shut down or reset. The data will be deleted only when you remove it by localStorage.removeItem(); Client side database is not recommended if you have huge amount of data or you need a central database which you should show to everybody who use this app in the world. in these cases its better, you use server side database
You can read a very nice article about how to use html5 local databases in XDK website:
https://software.intel.com/en-us/articles/html5-local-storage
2- You can use server database like MySQL or SQL server. however you need to connect your html codes to a PHP or asp.net script in a server by AJAX. You may use JSON for transfer data from PHP in server side to JS in the client side.
3- You can use cloud databases like Parse.com however Parse.com will be fully retired on January 28, 2017.
For local storage of a web or hybrid app you can use IndexedDB. There's a great tutorial on HTML5 rocks for a TODO list that you can follow: http://www.html5rocks.com/en/tutorials/indexeddb/todo/.
For remote databases, I like to use Parse.com to store data objects like for games I store user settings, high scores, etc. https://parse.com/docs/rest. Take a look at their Quickstart guide.
Hope that helps!
You could use LOCAL STORAGE the usage is pretty easy:
/* saving the data in Local Storage */
//yourData : this data could be an array, object or a plain string
window.localStorage.setItem('data', JSON.stringify(yourData));
/* retriving the data from local storage */
window.localStorage.getItem('data');
That's all, make sure your data doesn't exceed 5 MB.

Sync SQLite Database to App Engine Datastore?

The android app stores the data in SQLite database during the offline mode. When online I want the app to sync (in both direction) with the datastore(database) in cloud server (App Engine). How do I implement this functionality, so that I can show the data captured on phone on a web application. Also please suggest any simple alternative way if any..
I just write out my data as a String (using a format I can reconstruct my data with), pass that to AE, parse it and store/display it.
You could use json too.
or try http://mylifewithandroid.blogspot.jp/2010/10/client-server-communication-with-json.html
for the sync part I use a timestamp. If the timestamped result isn't recorded on the server, I record it. I send back the recorded stamps to the client and delete them from the store. Of course the server can also send back new results if a user's records were updated from a different client.
In general, you should implement some complex algorithm, that will be doing synchronization depending on your needs, and then make it in code on both side (server and client). This not quite a simple task, in general. Useful keywords for googling: SOAP, REST, JSON, ...

Categories

Resources