Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to android studio , i want to show the images from SQL server "image" data type in android studio. My web site is already running in production and which is working fine in hence it is not feasible to convert the images in other data type as it will require large testing . Pls help.

What I have tried:

I have checked on net , but not found any post on this.
Updated 7-Mar-16 5:04am

1 solution

Images are sent in the form of bytes array. you can access them by using a RestFUll api from sql server to your android application.
image will be retrieved in json and then converted to image from bytes array.
JSONArray jsonArray = new JSONArray(jsonString);
for (int i = 0; i < jsonArray.length(); i++) {
    JSONObject jsonObject = (JSONObject) jsonArray.get(i);

    byte[] byteArray =  Base64.decode(jsonObject.getString("image"), Base64.DEFAULT) ;
    Bitmap bmp1 = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);


bmp1 is the image, you can use it according to your needs
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900