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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:09:56+00:00 2026-05-31T05:09:56+00:00

This question is with regards to this one . Since it is a specific

  • 0

This question is with regards to this one. Since it is a specific question I moved that question by itself here. I have tried creating a text file, “foo.txt”, an read it into my Activity doing:

File file = new File("/assets/foo.txt");
if ( file.exists() ){
    txtView.setText("Exists");
}
else{
    txtView.setText("Does not exist");
}

The “foo.txt” file is located in my assets folder and I have verified that it exists in the OS. My TextView always gets the text “Does not exist” from the code above. I have tried going

File file = new File("/assets/foo.txt");
Scanner in = new Scanner(file);

as well, but this produces the following inline error: “Unhandled exception type FileNotFoundException”. Eclipse then suggest to involve try/catch, which removes the error but it doesn’t work properly then either.

I have also tried setting my assets folder to “Use as source folder”, but this does not make any difference. I have also tried using a raw folder as several people suggests to no use. I am out of options and really need help for this one. Should be easy…

Another try is to go

AssetManager assetManager = getResources().getAssets();
InputStream is = assetManager.open("assets/foo.txt");

but this produces the inline error in the second line: “Unhandled exception type IOException”.

  • 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-31T05:09:57+00:00Added an answer on May 31, 2026 at 5:09 am

    I’m with CommonsWare in that case (that’s the safe side 🙂 ), but it should be:

    AssetManager assetManager = getResources().getAssets();
    InputStream inputStream = null;
    
        try {
            inputStream = assetManager.open("foo.txt");
                if ( inputStream != null)
                    Log.d(TAG, "It worked!");
            } catch (IOException e) {
                e.printStackTrace();
            }
    

    Do not use InputStream is = assetManager.open("assets/foo.txt");

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

Sidebar

Related Questions

I have just asked this question an hour ago but with regards to IE8
I had posted a question in regards to this code. I found that JTextArea
I'm pretty sure this is a simple question in regards to formatting but here's
I bumped into an additional question that I needed in regards to this: Using
Now i know that this one is actually not a very technical question but
I have an application that is installed per-machine (since it uses a service). One
This question regards how one can effectively create and persist event domain objects on
First of all, this question is in regards to PHP and MySQL I have
This question is in regards to this blog entry. https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/ All the way at
I have few question in this regard When you create an internet page, does

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.