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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:29:27+00:00 2026-06-10T12:29:27+00:00

There’s something magic going on in one of my library projects. While layouts (res/layout)

  • 0

There’s something magic going on in one of my library projects. While layouts (res/layout) are fetched from the library project itself, files within the assets folder are fetched from the calling project (not the library project).

I’m currently building a help activity in a library project. The calling project gives a filename to the activity in the library project. The files are stored in the calling project – not in the library project.

When using the AssetsManager in the library project it uses the files from the calling project – not from the assets folder of the library project.

Is this correct behaviour?

Here’s the stripped down calling Activity in the root project:

// Calling Project
package aa.bb.aa;

public class MyListActivity extends ListActivity {

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);

        setContentView(R.layout.mylistactivity); // <--- Stored in resources of the calling project
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == R.id.men_help) {
            Intent intent = new Intent(this, aa.bb.bb.MyFileBrowser.class);
            intent.putExtra(MyConstants.FILE, "mylistactivity.html"); // <-- Stored in assets of the calling project
            startActivityForResult(intent, MyConstants.DIALOG_HELP);
            return true;
        }

        return super.onOptionsItemSelected(menuItem);
    }
}

And here’s the Activity in the Library project. I thought that assets are fetched from here and not from the calling Activity/Project:

// Library project
package aa.bb.bb;

    public class MyFileBrowser extends Activity {

        @Override
        public void onCreate(Bundle bundle) {
            super.onCreate(bundle);

            setContentView(R.layout.myfilebrowser); // <-- Stored in resources of the library project

            webView = (WebView) findViewById(R.id.browser);

            Locale locale = Locale.getDefault();
            String localeLanguage = (locale.getLanguage() != null) ? locale.getLanguage() : "en";

            Bundle bundleExtras = getIntent().getExtras();
            if (bundleExtras != null) {
                String file = bundleExtras.getString(MyConstants.FILE);
                if (!StringUtils.isEmpty(file)) {
                    String filename = "help-" + localeLanguage + File.separator + file;

                    AssetManager assetManager = getAssets();
                    InputStream inputStream = null;
                    try {
                        inputStream = assetManager.open(filename);
                    } catch (IOException ioException) {
                        filename = "help-en" + File.separator + file;
                    } finally {
                        try {
                            if (inputStream != null) {
                                inputStream.close();
                            }
                        } catch (IOException ioException) {
                        }
                    }

                    webView.loadUrl("file:///android_asset" + File.separator + filename); // <-- Uses file in assets of calling project - not library project
                }
            }
        }
    }
  • 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-10T12:29:29+00:00Added an answer on June 10, 2026 at 12:29 pm

    Found the answer. assets are always used from the referencing project. A library project can’t hold assets. I found it on this page:

    Library Projects

    Here’s the part of the doc that does describe this:

    The tools do not support the use of raw asset files (saved in the
    assets/ directory) in a library project. Any asset resources used by
    an application must be stored in the assets/ directory of the
    application project itself. However, resource files saved in the res/
    directory are supported.

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

Sidebar

Related Questions

There is something strange happening. Param interceptor is the one in charge to take
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There are two table s : one is the master and one the detail
There are several shading languages available today like GLSL, HLSL, CG, which one to
There's a few previous questions on StackOverflow questioning how one goes about accessing local
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch
There is some contradiction in the api documentation: on one location: https://developer.foursquare.com/docs/responses/user on another
There are many tutorials that talk about deleting index.php from the url. But I
There seems to be only one way to get media to autoplay in iOS

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.