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 8838611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:02:50+00:00 2026-06-14T10:02:50+00:00

Hi I learned how to grab data from a SQL and display onto TextView.

  • 0

Hi I learned how to grab data from a SQL and display onto TextView. But I’m having little trouble displaying images.

The images are stored in the SQL database as URL but I can’t display as an image onto the view.

I’ve done some research and found on “How to display image with given URL”, but I’m just having a little difficulty understanding the concept of grabbing the URL and display .. Please kindly help me. Thank you!

This is the errorLog i’m getting.

Update
Line 159 : photoMe.setImageDrawable(drawable);

11-15 14:53:21.450: W/LoadImageFromWebOperations(28444): java.net.MalformedURLException: Protocol not found: photo
11-15 14:53:21.480: D/AndroidRuntime(28444): Shutting down VM
11-15 14:53:21.480: W/dalvikvm(28444): threadid=1: thread exiting with uncaught exception (group=0x40c55a68)
11-15 14:53:21.500: E/AndroidRuntime(28444): FATAL EXCEPTION: main
11-15 14:53:21.500: E/AndroidRuntime(28444): java.lang.NullPointerException
11-15 14:53:21.500: E/AndroidRuntime(28444):    at com.app.android.DirectoryDetailMeActivity$GetDirectoryDetails$1.run(DirectoryDetailMeActivity.java:159)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at android.os.Handler.handleCallback(Handler.java:605)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at android.os.Looper.loop(Looper.java:137)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at android.app.ActivityThread.main(ActivityThread.java:4517)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at java.lang.reflect.Method.invokeNative(Native Method)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at java.lang.reflect.Method.invoke(Method.java:511)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
11-15 14:53:21.500: E/AndroidRuntime(28444):    at dalvik.system.NativeStart.main(Native Method)



public class DirectoryDetailMeActivity extends Activity {

    ImageView photoMe;
    TextView txtName;

    String uid;

    String photo = "";

    private ProgressDialog pDialog;

    JSONParser jsonParser = new JSONParser();

    private static final String url_veiw_directory = "directory_detail_me.php";

    private static final String TAG_ID = "uid";
    private static final String TAG_IMG = "photo";
    private static final String TAG_NAME = "name";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);         
        setContentView(R.layout.directory_detail_me);

        uid = i.getStringExtra(TAG_ID);

        new GetDirectoryDetails().execute();

    }

class GetDirectoryDetails extends AsyncTask<String, String, String> {

    protected String doInBackground(String... params) { 

    runOnUiThread(new Runnable() {
        public void run() {

        int success;
            try {

            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("id", uid));

            JSONObject json = jsonParser.makeHttpRequest(url_veiw_directory, "GET", params);

            Log.d("my profile", json.toString());

            success = json.getInt(TAG_SUCCESS);
            if (success == 1) {
            JSONArray directoryObj = json.getJSONArray(TAG_DIRECTORY); 
            JSONObject directory = directoryObj.getJSONObject(0);

            txtName.setText(directory.getString(TAG_NAME));

            Drawable drawable = LoadImageURL(TAG_IMG);
            photoMe.setImageDrawable(drawable);                             

            txtName = (TextView) findViewById(R.id.name);
            photoMe = (ImageView) findViewById(R.id.photo);                         

            }else{

            }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            private Drawable LoadImageURL(String url)
            {
                try
                {
                    InputStream is = (InputStream) new URL(url).getContent();
                    Drawable d = Drawable.createFromStream(is, "photo");
                    return d;
                }
                    catch (Exception e)
                {
                    Log.w("LoadImageURL",e.toString());
                    return null;
                }
            }
            });

            return null;
        }

    }
}
  • 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-06-14T10:02:52+00:00Added an answer on June 14, 2026 at 10:02 am

    You don’t seem to understand an AsyncTask. The point is that it does not run on the UI thread, making it possible to do long term IO like HTTP connections. Wrapping the entire doInBackground in a runOnUIThread is completely counter to that. Its not your only problem, but its on the list.

    The rest is too hard to read due to formatting, but look on line 159. Some variable you’re using there is null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to grab a table from a HTML to get the data contained
I learned that class fields are stored in the heap, but where are methods
I learned quite a bit of scheme from SICP but am more interested in
I have just learned about XPath and I am wanting to read data from
I learned of gist.github.com from Mozilla Ubiquity , and have been using it to
I learned something about DLL's yesterday. But I haven't found the way how to
I learned from this article that to avoid confliction between javascript libraries, use jQuery.noConflict();
I learned c++ on and off for several times but never write a real
I learned enums when I learned C and from time to time I keep
I learned that it's recommended to use BigDecimal instead of Float , but this

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.