I have an android app which populates a SQLite database with numerous latitudes and longitudes. I then need that data to be stored in an external SQL Server db. The problem I'm having is sending that file to a web service. I cannot find any examples on how the class should look that takes in the db file and stores it in a separate SQL Server db. Is this even the way I should be approaching my problem?
A better approach would be to send the actual lat/long data to db via a web service rather than sending the entire db file itself.
Doing it in this way would accomplish several things:
It should be much simpler to implement
You would not need to support SQLite on the server side, just the client
The data "set up" would be immediately available for querying - rather than needing to be extracted from the SQLite db file before it can be used
EDIT: How frequently and how much you upload is entirely up to you. You can make it user-activated or on some time interval and upload the latest data in bulk fashion or one-at-a-time until you're up to date. In either case you would track which data needs to be uploaded with a timestamp.
One simple method for transfering "in bulk" would be to pull the data that you need to save from you SQLite db and put it into a JSON or XML object which would be interpreted on the server as a collection of lat/long data. This would put the whole upload into a single web service call rather than having to loop through your "newest" records and calling a web service for each item.
Rather than sending a database to server you should have a mechanism that can export only data and send it to the database.
You can export the data into the CSV file or any other format and then you can send it to the sever so that server can easily read that CSV and insert that data into the database.
Also you can read your SQLite database and then you can make a structured data like XML, JSON.
then you can connect to the webservice and then send thay structured file to the server.
CSV is the best option if you have much data and you want to send it to the server.
Related
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)...
I have a problem with my application. I need the data from my MySQL-Database on the server. Usally I'm using HTTP-Posts, but this time I'm have to get a lot of db-Entrys. So I thought, that i'm just copying the database to the device. But here is the next problem: The Database on the device has the same structure like the db on the server, and additional 2 extra tables, to save some local data.
Finally my question is, how to get a lot of data from my database?
One extra question: is it possible/effective to use 2 local databases? So i could use 1 for local data and the other one for the server data. Then it would be possible to copy the db, but i need also an mysql-query, because i don't want to copy the whole data.
Yes, is possible to have 2 local db, and the best way to download an entire db from server is to dump the mysql db on server to a sqlite db, and so you may download the sqlite db from your mobile app.
Well choosing a database is depends on your project requirement. If your data is getting updated frequently on server and you want the display the updated data to the user. Do not copy database in mobile. Instead of it use webservices to get data from remote server.
And Yea, you can create two database in Android, nothing wrong in it. But again I would suggest that for only two tables do not create separate database.That can be merged in single database.
Summary
Frequently Updates in Data : Use MySql + Webservice
Static Data : Go for local db
I am building an Android app that that involves taking pictures and adding text to it. In other apps I have built I have been storing the data locally as JSON data. I read that you should always save locally(JSON) at every step because you can never be sure when an activity will be stop.
In the app I am currently building I want to upload the data to a SQL database. For example want to take a picture, save it locally and edit it(while saving at every edit), and then upload it to server. Then I would want to display a list that accesses the database to display finished photos.
Can I continue to save things with JSON and then only upload certain things to the database or should I skip JSON and just go directly to database?
Is there any built in methods for sending JSON data to a SQL database? Just trying to figure out the best way to go about this. Any advice would be appreciated.
I would not store the data as JSON because you might need later to query the data or filter it which will be cumbersome to do it with JSON.
What I suggest that you store your data in sqlite (the text only) and then when you are about to send to the server you can serialize it as JSON.
There is no special method to send JSON data, it is just normal plain text over HTTP.
As general rule, data storage should be in a database and then you can use JSON (or XML) to exchange the data (e.g. sync it with the server)
Also, if you are sending large amount of data, consider compressing it before sending to the server
In my application I am having database stored on the web server, I want to fetch particular values of record stored in SQL database. After getting that values want to update these values in the record stored in SQLite database of android.
Scope of question is very broad can't answer in few lines, but can give you idea. For achieving above functionality there is no any such mechanism so that android client (like tablet/mobile) directly get connected to web servers. For making this happen you need to write web services at server side which will take request from android client, process it as per request types and returns the resulted processed data. You can consume this web response at client side and do operations like saving it in Sqlite database. Similarly you can sync local sqlite database with server via web services only. You can easily consume Restful web services using Retrofit or Volley.
I have an Android application with a SQLite database from which I want to send some data to a webservice to store it in a database there.
How would I go about doing this? Is there a smart way of doing it?
I've thought about just extracting the data from the SQLite database and create an XML file to hold and then send the XML file to the webservice, but is there a easier/better way of doing this?
JSON is generally seen as a more efficient data format for transferring to and from mobile devices. Check out this post about how to do it. You will, of course, need a web service that can accept and interpret JSON objects.