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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:21:34+00:00 2026-05-27T22:21:34+00:00

I was having a problem where I couldn’t read in a file in Android

  • 0

I was having a problem where I couldn’t read in a file in Android and found that it was because the file could not be located. I have now created a bare bones program:

public class LoginView extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loginpanel); 
    Button button = (Button) findViewById(R.id.btnLogin);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            ReadingTest rt = new ReadingTest();
        }
    });
}

ReadingTest.java

public class ReadingTest {

private BufferedReader br;

public ReadingTest () {
    try {
        br = new BufferedReader (new FileReader("profiles"));
        System.out.println("BufferedReader was successful...");
    } catch (FileNotFoundException e) {
        System.out.println("BufferedReader was unsuccessful...");
        e.printStackTrace();
    }
}

This program should read the profiles file which I have placed in the same place as the AndroidManifest.xml file, i.e. in the project root. The program prints whether it was successful or not, and unfortunately it’s printing unsucessful. Can someone tell me where to place the file and how to access it via the BufferedReader? My whole java project which I am trying to port relies on reading and writing to files so I can’t progress until this is done. Thanks in advance!

EDIT: Ok, after doing some more research I can open my file in my main activity!! I placed the profiles.txt file in the res/raw folder in my main activity I wrote the following code:

is = this.getResources().openRawResource(R.raw.profiles);
    br = new BufferedReader(new InputStreamReader(is));

For some reason my BufferedReader can read the file in the main activity, but if I try to create a BufferedReader using the same code in a separate class, and then proceed to try to call said class it shuts down the the VM and comes up with a FATAL EXCEPTION: main in the logcat. Any ideas how I can change the above code to make it work?

  • 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-27T22:21:35+00:00Added an answer on May 27, 2026 at 10:21 pm

    Have you tried using Assets?

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

Sidebar

Related Questions

I've already looked around but couldn't find the exact solution/problem I'm having right now.
We are having problem with the server migration. We have one application that are
I have a small problem but couldn't find solution for that. I have founded
I am having a problem with LINQ and I was hoping someone could explain
I'm having the following problem and wondered whether anyone could see why this is
I wonder if anyone could help me with a problem I've been having. I
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I'm having problem when running my Windows Forms program. In the program, I have
I have been stuck with this problem for a while now, and I just
I am having a problem in mysql query, I have date saved in database

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.