Convert mysql data to protobuf - android

I have a HTTP server to respond to the rest requests from a mobile devices. Server data won't change frequently so I am thinking to store the data inside the devices. The data is read only for the users. So I am thinking to share the whole db with the devices as a file. If I update the db, I will create this file again. When user open the application, it will check for update time from the server. If there is an update, the device will download new file. I need to convert MySql db into the Android and IOS readable file. Protocol-buffers can easily read from the both platforms. Are there any way to dump MySql data into a protobuf. Or should I use a different mechanism?

Related

Transferring data from Sql server to SQLITE with Android

I have software that connects to an SQL database. I am now working on the software on Android, using SQLite, and need to transfer the SQL database (with the data) to SQLite.
How can I do this?
One way would be to create the SQLite database on the device and download and persist the data into the local SQLite data base. A good place to read up on how to do this is in the Android docs.
Another possible solution would be to create the SQLite database at the server level and download it directly within the Android app then open it. But if you modify anything locally within the app you would need to send data back to the server to keep in sync.
Create Rest API that will fetch my SQL data in JSON format.
Now from android app access that API to get data and insert that data in in your SQLite.
or if you want to fetch it in background process use sync Adapter.

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)...

Accessing external database from Android app

I have a sqlite database with about 15MB of data (too large to store on each device). I am building an app to interact with this data. How to go about accessing the database from wherever the app is being stored. I'm not asking someone to do it for me, but where do I go about researching how to do this. Is there an android module that does just this after being passed an ip address (or FTP Server IP?). Where do I start researching the best way to host my database and then link it to my app? What's the high level brief of how this is accomplished? Thanks!
Two ways
You can send a query to the web server and retrieve the result (you need the web server URL that received your query and send the result through HTTP).
You can download the database and put it in the app database directory and then you can query this database.

internet database to android app

I want the users of my app to view an internet database, download some records of it into the database that is built in the app (not online db) and also to be able to upload some records to the online database.
I already have the database inside my app and my question is how can I make an online database that my android app could see, download from and upload to?
Android supports JDBC poorly - or let's be honest, not at all. Your best option is to create a Web server that wraps your database to a REST API. PHP is the most common language, while not the best, a lot of tutorials and snippets are available, so I would go with that. You'll have to wrap your database requests into HTTP requests and send it to the server.
For every query you'll plan on running, you'll have to create a PHP script that receives the HTTP parameters, builds the SQL query, and creates a structured XML or JSON response from the received data. This XML or JSON will than be sent to the Android client where you can parse it and obtain the data, do your syncing or such. I would suggest JSON, it's easier to read when debugging, consumes less bandwidth and has an easy to use parser in the Android API.
An easy lecture on PHP web service basics.
On using databases from PHP.
HTTP in Android.
JSON in Android.
Your online database should be on some server and you need to write a webservice to communicate your app to this online database(downloading and uploading purposes). your websrvice will also be hosted on some server. You then will be making webservice calls from your app to perform required modification to the online database.

How android application synchronize data with backend server?

Backend server has tables, and the android client have the same tables. Are there any way to synchronize data between them?
From your question I understand that There are tables on mobile and server both are same. Now you want to take a data from server from mobile and from to Server. Use upload and Download. When your application get started download the data from the server Process on that data after that upload that data to the server. so that both your mobile and server db remain updated.
for upload and download you can use following links:
http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/
http://www.vogella.de/articles/AndroidJSON/article.html
You have to use the JSON.

Categories

Resources