ZXingIT
ZXingIT

Reputation: 345

Get images from remote SQL database using PHP to Android SQLite database

I am trying to develop an Android app that will connect to a remote SQL database using PHP. I have images stored in the remote SQL database as BLOB. (For example a table with student id, student name, student image) I will need to save this data onto my Android database.

I have read that using JSON is a good way but is unable to find any good samples on saving the image blob from PHP to the Android database. I would appreciate if you can guide me on both the server side and the client side. Thanks.

Upvotes: 0

Views: 1349

Answers (1)

NSjonas
NSjonas

Reputation: 12032

The reason your not finding any examples using blob is because storing images as a blog is highly warned against. I had the exact same problem as you and eventually decided to switch over and store the images in the file system and only a path in the db. This makes it much easier to get the images over to android.

Its an especially bad idea to store images as blob on android for several reasons, the biggest that a object can never excede 1 meg. So if your trying to create a DB cursor to display your items in a list view then you will be limited to 1-10 items before your app crashes. I speak from experience.

If you want more info, leave a comment. gotta run to class for now.

Upvotes: 3

Related Questions