ZeroSkittles
ZeroSkittles

Reputation: 164

Sending SQLite db to web service

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?

Upvotes: 4

Views: 3375

Answers (2)

Dharmendra
Dharmendra

Reputation: 33996

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.

Upvotes: 0

Paul Sasik
Paul Sasik

Reputation: 81479

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.

Upvotes: 3

Related Questions