send images from remote server to mobile - android

I have a web platform in which the user enters the data, which are stored in SQL database. Using restful services and json I send the data in my mobile application via http calls, and I save them in sqlite database. The above works perfect. Now I want to upload images in web platform (which will saved in a separate table in SQL server) and in continue I want to get the images in mobile app, in the way which I have done for other data. After a lot research in google I found the blob data type. So , if I save the images as blob in sql then how can I convert them as json objects? Moreover, I want to know if it is efficient.

two ways to do that ( Base64 and byteArray ) by using Gson or Jackson, your byteArray shall automatically be converted to string if the variable is declared as string.

Related

Convert mysql data to protobuf

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?

Android data best practices

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

Which is better in performance aspect :remotely MySQL DB , store data in form of xml , json while working with android

I've just started my app in android.And i want my app should not consume much CPU of device.
I have 3 choice for data accessing .
1 . MySQL Database on remote server.
2 . Data stored in form of xml on remote server
3 . Data stored in form of json on remote server.
Data is approx 2000-3000 rows in database.
Which approach should i use for better performance of my app.
Any help will be appreciable.
How your data is stored on the remote server is of little concern to the android app. The real question is how it's transferred, and how you handle and store it locally.
With this much data, your best bet is to use to stream the data and parse the stream. For XML, that would mean using the SAX parser, for JSON probably streaming Jackson. JSON uses less bandwidth and Jackson is hands-down the fastest way to churn through formatted data.
Streaming has the obvious advantage that you do not need to keep all this data in memory to parse as DOM, but it comes at the cost of a higher development effort.
Locally, the best way to store this amount of data would be a sqlite database, which you can easily query.

How to fetch particular values of record from SQL databse stored on server and update that values in SQLite database of android?

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.

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

Categories

Resources