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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:26:16+00:00 2026-06-15T02:26:16+00:00

Please Help…. Ive created and App for Android 2.2 that creates a text file

  • 0

Please Help….

Ive created and App for Android 2.2 that creates a text file and saves to sd card.
In another activity, it reads this file and stores into arrays.
The App worked fine on 2.2, and worked perfectly well on my samsung nexus with 4.1. (ICS)
However i have just updated to jelly bean (4.2) and the App now crashes when attempting to open the file.
Ive read the documentation about adding read permission in the manifest for 4.2, and added this but the App still crashes.
No log cat as it works fine on emulator, but not on my phone.

Are there any special permissions required for 4.2 or different way of opening files for reading?

Here is my code for creating directory and writing file…

 //Create Reports Folder...........................................
      File directory = new File 
      (Environment.getExternalStorageDirectory().getPath()+"/PatRecords");
              if (!directory.exists()) { 
                      directory.mkdir(); 


                      Toast.makeText(this, "NEW FOLDER CREATED", Toast.LENGTH_SHORT).show();
              } 

            //If Sd card available, and writable with no errors, then write file.........
            if ((mExternalStorageAvailable = true)&(mExternalStorageWriteable = true)&(Error==0))
                {       

                try {
                    File ReportFile = new File(directory.getPath()+"/"+FileName$);
                    ReportFile.createNewFile();

                    FileOutputStream fOut = new FileOutputStream(ReportFile);                   
                    OutputStreamWriter OutWriter = new OutputStreamWriter(fOut);

                    OutWriter.write(Tester$+"\r\n");
                    OutWriter.write(Company$+"\r\n");
                    OutWriter.write(Customer$+"\r\n");
                    OutWriter.write(Address1$+"\r\n");
                    OutWriter.write(Address2$+"\r\n");
                    OutWriter.write(PCode$+"\r\n");
                    OutWriter.write(Instr$+"\r\n");
                    OutWriter.write(Serial$+"\r\n");

                    OutWriter.close();
                    fOut.close();

                    Toast.makeText(this, "NEW FILE CREATED", Toast.LENGTH_SHORT).show();

                } catch (Exception e) {
                    Toast.makeText(getBaseContext(), e.getMessage(),
                            Toast.LENGTH_SHORT).show();
                }//End of try/catch


              }//End Write.....

And here is the code for reading…. works ok upto 4.1 just not 4.2…

FilePath=getIntent().getStringExtra("FileToOpen");

    //Open File and read first all data.......
    try {
        BufferedReader br = new BufferedReader(new FileReader(FilePath));

        Tester$ = br.readLine();
        Company$ = br.readLine();
        Customer$ = br.readLine();
        Address1$ = br.readLine();
        Address2$ = br.readLine();
        PCode$ = br.readLine();
        Instr$ = br.readLine();
        InstrSerial$ = br.readLine();
        NumOfTests$ = br.readLine();        
 br.close();
          Toast.makeText(this, "FILE LOADED OK.", Toast.LENGTH_SHORT).show();

          n = n+1;    //Increment n for next test number....

    }
    catch (IOException e) {
        //You'll need to add proper error handling here
        Toast.makeText(getBaseContext(), e.getMessage(),
                Toast.LENGTH_SHORT).show();

Any help much appreciated … Thanks for looking

  • 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-15T02:26:17+00:00Added an answer on June 15, 2026 at 2:26 am

    In answer to my own question, android 4.2 allows for multiple users,
    and now files can be opened unless they were created by that user.
    As the file i was trying to read was created in 4.1, it would not
    allow the App to open and read it.
    I ran the App and created a new file, and it works fine.

    Hope this may help anyone having similar problems.

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

Sidebar

Related Questions

please help so here is the problem i got a rails app that sends
Please help me get to the bottom of this...the only file that this error
Please help me, I'm trying to find some documentation about pre-installed applications at Android.
please help me to insert a date from a text box in dd-mm-yyyy format
Please help I have 3 ImageViews and I can move that 3 views with
Please help, I am stuck here --- irb> a = line of text\n line
Please help me: create clickable regions in the canvas below that I can assign
Please help me I'm developing an android application to display a pinch zoom-able and
Please help me this question. Example I have Activity class MyActivity. I start this
please help me. example inf file : ;============================================================================= ; ; Copyright (c) Intel Corporation

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.