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

  • Home
  • SEARCH
  • 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 8738703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:47:04+00:00 2026-06-13T10:47:04+00:00

i have problem with file writing. I want to create OnClick method of button

  • 0

i have problem with file writing. I want to create OnClick method of button that add line to file on sdcard but instead it delete previous line and put all content in place of current one. In result i got only the Text i put at the last click of Button, here is my code:

if (txtFile.createNewFile() || txtFile.isFile()) {
                        FileOutputStream fOut = null;
                        try {
                            fOut = new FileOutputStream(txtFile);
                        } catch (FileNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
                        BufferedWriter bwriter = new BufferedWriter(myOutWriter);
                        EditText desc__ = (EditText)findViewById(R.id.descriptionEditTExt);
                        try {
                            bwriter.newLine();
                            bwriter.write(lat+"|"+lng+"|"+desc__.getText().toString()+"|"+f+"|"+position);

                            bwriter.close();
                            myOutWriter.close();
                            fOut.close();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    } else {
                        /* handle directory here */
                    }
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
  • 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-13T10:47:05+00:00Added an answer on June 13, 2026 at 10:47 am

    Please rewrite your FileOutputStream constructor as

    FileOutputStream fos = new FileOutputStream(file, true);
    

    here is suggests that your file will be opened in the append mode which will solve your first problem..

    secondly if you want to add new line to the file use "\r\n" string

    e.g. fos.write("\r\n".getBytes());
    

    Hope this helps..

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

Sidebar

Related Questions

i have a very small problem. I am writing a file to sdcard. I'l
I have problem with session in cakephp.I have one file chat.php that is in
I become use raw socket and i have this problem: bad file descriptor the
I have problem with copying sdf file to WM emulator. My solution structure MyApp.DataLayer
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have a problem downloading particular file types by WebClient. So there are no
I have a problem to Store file (from a remote API) in MongoDB, i'm
I have problem with TableView its empty. In (.h) file: @interface TableViewController : UITableViewController{
i have problem.. for(a=1;a<10;a++){ $(.div).append(<div id=+a+></div>) $.ajax({ url: file.php, data: a=+a, type: POST, async:
I have a problem parsing a XML file which contains special characters like ,

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.