Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:15:31+00:00 2026-05-25T15:15:31+00:00

How can i get image from image url in image view. My imageUrl is

  • 0

How can i get image from image url in image view.
My imageUrl is coming from databaseadapter.

In Fields class LocationImage dataype is string but in setBackgroundResource method it is asking for int value as parameter. LocationImage url is getting from database, so that i’ve taken that as string variable.

code lines are here.

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class FindPlaces extends ListActivity{

    private SQLiteDatabase DbLoc;
    ListView lv;
    int val;
    private ArrayList<Fields> results = new ArrayList<Fields>();
    @Override
    public void onCreate(Bundle savedInstance) {
        super.onCreate(savedInstance);
        setContentView(R.layout.places);
        getallLocs();
        setListAdapter(new StudentListAdapter(this,  val, results));
    }

    class StudentListAdapter extends ArrayAdapter<Fields>{
        private ArrayList<Fields> locationDetails;
        private Context mContext;

        public StudentListAdapter(Context context,int textViewResourceId, ArrayList<Fields> results) {
            super(context, textViewResourceId, results);
            // TODO Auto-generated constructor stub
            System.out.println("Constructor StudentList Adapter...");
            this.locationDetails = results;
            mContext = context;
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return results.size();
        }
        @Override
        public Fields getItem(int position) {
            // TODO Auto-generated method stub
            return locationDetails.get(position);
        }
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return super.getItemId(position);
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            View v = convertView;
            if(v == null){
                LayoutInflater vl = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vl.inflate(R.layout.placeslist, null);
            }
            Fields o = results.get(position);

            if (o != null) {
                TextView iv = (TextView)v.findViewById(R.id.toptext);
                TextView tv_sNo = (TextView)v.findViewById(R.id.toptext1);
                ImageView tv_Image = (ImageView)v.findViewById(R.id.Locimage);

                iv.setText(o.getLocationName());                            
                //tv_sNo.setText("Status: "+ o.getOrderStatus());
                tv_sNo.setText(o.getLocationImage());   
                tv_Image.setBackgroundResource(o.getLocationImage());
            }
            DbLoc.close();
                            return v;
        }       
    }
    static class ViewHolder
    {
        TextView Locationname;
        ImageView Locationimage;
    }
    private void getallLocs() {
        // TODO Auto-generated method stub
        try {
            DatabaseHelper dbHelper = new DatabaseHelper(
                    this.getApplicationContext());
            DbLoc = dbHelper.getWritableDatabase();
            Cursor c = DbLoc.rawQuery("SELECT " + DatabaseHelper.LocationName+ " , " + DatabaseHelper.LocationImage + " FROM "
                    + DatabaseHelper.LOCATIONTABLE , null);
            System.out.println("SELECT " + DatabaseHelper.LocationLang+" , "+DatabaseHelper.LocationLat+" , "+ DatabaseHelper.LocationName
                    + " ," + DatabaseHelper.LocationImage + " FROM "
                    + DatabaseHelper.LOCATIONTABLE );
            if (c != null) {
                if (c.moveToFirst()) {
                    do {
                        String LocationName= c.getString(c.getColumnIndex("LocationName"));
                        String Mobile = c.getString(c
                                .getColumnIndex("LocationImage"));
                        Fields p = new Fields(LocationName, Mobile);
                        results.add(p);

                    } while (c.moveToNext());
                }
            }
        } catch (SQLiteException se) {
            Log.e(getClass().getSimpleName(),
            "Could not create or Open the database");
        } 
                }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:15:32+00:00Added an answer on May 25, 2026 at 3:15 pm

    if u got image url use the below code to set the image from url to imageview

    Bitmap mbmp = BitmapFactory.decodeStream(new java.net.URL("urlname").openStream());
    Imageview_ref.setImageBitmap(mbmp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that I can't seem to get the image from my bundle
can any one guide me how to get parameter specially image from the given
How can I get an image to stretch the height of a DIV class?
Probably I'm just missing something obvious, but I can't get the image in my
I'm trying to get an image from an URL and it doesn't seem to
I am try to get the image from this url. http://open.mapquestapi.com/staticmap/v3/getmap?type=map&size=225,160&pois=purple-1,51.466407,-0.952418,0,0%7Cpurple-2,51.466102,-0.958293,0,0%7C&center=51.466252499999996,-0.9553555&zoom=12&key=Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh&rand=2031817700&session=4eeb5481-00f2-0000-02b7-64f1-002655800398 I can successfully
Given a path and filename how can I get the Image object: Image image
If I open an image with open(image.jpg) , how can I get the RGB
i search online but can't get satisfactory result i want to protect images on
I can get easily see what projects and dlls a single project references from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.