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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:55:23+00:00 2026-05-25T23:55:23+00:00

I am using the following code to set an image from the assets folder.

  • 0

I am using the following code to set an image from the assets folder.

Uri numBgUri = Uri.parse("file:///android_asset/background_numbers.png");
numBgImage.setImageURI(numBgUri);

The background_numbers.png file definitely exists in the assets root directory. I am getting a FileNotFoundException in the log: –

09-23 17:05:23.803: WARN/ImageView(23713): Unable to open content: file:///android_asset/background_numbers.png

Any ideas what I could be doing wrong?

Thanks!

  • 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-25T23:55:24+00:00Added an answer on May 25, 2026 at 11:55 pm

    I managed to get a viable workaround for this using my own custom ContentProvider (It’s easier than you think!). Thanks to skink on Google Groups for the tip

    This code should work, you just need to set a provider URL and register it as a provider in the manifest file

    package sirocco.widgets;
    
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    import android.content.ContentProvider;
    import android.content.ContentValues;
    import android.content.res.AssetFileDescriptor;
    import android.content.res.AssetManager;
    import android.database.Cursor;
    import android.net.Uri;
    
    public class AssetContentProvider extends ContentProvider {
    
        private AssetManager mAssetManager;
        public static final Uri CONTENT_URI = 
                Uri.parse("content://your.provider.name");
    
        @Override
        public int delete(Uri arg0, String arg1, String[] arg2) {
            return 0;
        }
    
        @Override
        public String getType(Uri uri) {
            return null;
        }
    
        @Override
        public Uri insert(Uri uri, ContentValues values) {
            return null;
        }
    
        @Override
        public boolean onCreate() {
            mAssetManager = getContext().getAssets();
            return true;
        }
    
        @Override
        public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
            return null;
        }
    
        @Override
        public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
            return 0;
        }
    
        @Override
        public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
            String path = uri.getPath().substring(1);
            try {
                AssetFileDescriptor afd = mAssetManager.openFd(path);
                return afd;
            } catch (IOException e) {
                throw new FileNotFoundException("No asset found: " + uri);
            }
        }
    
    }
    

    I hope this helps any googlers out there with the same problem!

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

Sidebar

Related Questions

I'm using the following line of code to open an Image from a file:
I am using the following code to call a batch file: dim shell set
i am using following code to set an image as submit button *<input type=submit
I have set imageView's frame in table using the following code. cell.imageView.image = [UIImage
I am using the following code to set a tray icon in Windows and
I am using the following code to apply a hover effect to a set
I'm using following code but cannot return data from MySQL. This is the output:
The following code transfers an image that is created on the fly from a
I am currently using the following code to get an UIImage from an ALAsset
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,

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.