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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:53:29+00:00 2026-05-23T09:53:29+00:00

I’m creating an App for displaying images from a previously specified source. I will

  • 0

I’m creating an App for displaying images from a previously specified source. I will be downloading these images if a version file has changed. If there is no internet connection available, it will display the local images I have previously downloaded.

For this, I am using an ImageView and Drawable objects like this:

String imageName = Startseite.FILENAME_PRE + "1" + Startseite.FILENAME_POST;
Drawable d = Drawable.createFromPath(imageName);
mImageView.setImageDrawable(d);

I triple checked via DDMS that the file specified (in this case “page1.jpeg”) does indeed exist in the directory “data/data/out.path/files/image1.jpeg”. However, in the above code example the second command returns a null object. The file is readable and writable by normal means (streams), but it seems the ImageView doesn’t like the image.

I’m not sure how to proceed from here. It could either be that I am missing a crucial security element that allows for the display of images. Or, maybe the image cannot be displayed. Is there a tool to check for displayable images?

Thank you for your time.

Edit 1: I have changed the code to this:

String imageName = Startseite.FILENAME_PRE + "1" + Startseite.FILENAME_POST;
String imageNameWithPath = getApplicationContext().getFilesDir().getPath() + '/' + imageName;
Drawable d = Drawable.createFromPath(imageNameWithPath);

This creates the Drawable object successfully. Sadly, when assigning the object via SetImageDrawable(), my debugger goes nuts and reads 4 exceptions in classes I have never heard of (most probably some Android interna). I have checked for a double slash (because I copy one to the end), but the path looks clean.

Edit 2: Sadly, the same happens when I create the drawable from a stream and not download the image beforehand.

Edit 3: Here is the LogCat snippet of when the application fails.

06-28 08:14:32.323: WARN/dalvikvm(21462): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
06-28 08:14:32.323: ERROR/AndroidRuntime(21462): Uncaught handler: thread main exiting due to uncaught exception
06-28 08:14:32.343: ERROR/AndroidRuntime(21462): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.ourcompany.apps/de.ourcompany.apps.Startseite}: java.lang.NullPointerException
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.os.Looper.loop(Looper.java:123)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread.main(ActivityThread.java:4363)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at java.lang.reflect.Method.invokeNative(Native Method)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at java.lang.reflect.Method.invoke(Method.java:521)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at dalvik.system.NativeStart.main(Native Method)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462): Caused by: java.lang.NullPointerException
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at de.ourcompany.apps.Startseite.displayImages(Startseite.java:61)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at de.ourcompany.apps.Startseite.onCreate(Startseite.java:42)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
06-28 08:14:32.343: ERROR/AndroidRuntime(21462):     ... 11 more
06-28 08:14:32.373: INFO/Process(64): Sending signal. PID: 21462 SIG: 3
06-28 08:14:32.373: INFO/dalvikvm(21462): threadid=7: reacting to signal 3
06-28 08:14:32.373: ERROR/dalvikvm(21462): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

I tried the version using the BitmapFactory.decode() method, sadly it results in an exception as well.

What I can add: The following code stems from a video tutorial:

    String mUrlString = "http://www.android.com/images/gingerdroid.png";
    try {
        mImageView.setImageDrawable(
            Drawable.createFromStream(
                    (InputStream) new URL(mUrlString).getContent(), 
                    "qrcode")
        );
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

This code works in the tutorial, yet it exits with the exact same image the same way that my tries do so far.

Hope this helps.

Edit 4: The problem has kinda resolved itself. I created the project anew, copypastad the old source, created the VM anew, suddenly it works. If it was the old project or the VM, I cannot say for sure.

  • 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-23T09:53:30+00:00Added an answer on May 23, 2026 at 9:53 am

    I think you must use the full path.

    A safe way of getting the path is by using the following:

     Context context = getApplicationContext(); // or other way of getting current context
    
     String dir = context.getFilesDir().getPath();
    

    Good luck!

    [EDIT]: In response to your edit. Can you post a logcat output?

    [EDIT 2]: See below for code on how I would go about this.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back 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.