Krishna
Krishna

Reputation: 4984

How to retrieve image from MySQL using JSON in Android?

For my android application I want load image from remote MySQL database to the Gallery View using JSON. Is it possible or not.

possible means any one help me with some sample code based on this

Upvotes: 1

Views: 4173

Answers (1)

Basil
Basil

Reputation: 2173

This is possible. First of all you need to get the image url saved in the remote server. That can be made possible by an api call either by using JSON or any other mode. By that api you can retrieve the image url's saved on the remote database. After getting all the image url's you can load the images using Lazy load of images in ListView. On the LazyLoading code they have used a ListView in the layout so the images and the corresponding text are shown as list items, you can change that ListView to a Gallery something like this:

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Gallery android:id="@+id/gallery" android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Clear Cache"/>
    </LinearLayout>

I think this will get you the desired result.

Upvotes: 1

Related Questions