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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:52:55+00:00 2026-05-23T23:52:55+00:00

I’m trying to create a simple Android app which saves a text from an

  • 0

I’m trying to create a simple Android app which saves a text from an EditText form and store it in internal memory. Everything seems to work fine (the “Saved” message appears) except when I quit the activity and restart it, the saved text from file does not load at all. Am I missing something here?

public class ModifyInfo extends Activity{

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit);

    Bundle extras = getIntent().getExtras(); 
    if(extras != null){
        int dayNum = extras.getInt("day");
        String dayName = "";

        switch(dayNum){
        case 1:
            dayName = this.getString(R.string.dayMon);
            break;
        case 2:
            dayName = this.getString(R.string.dayTue);
            break;
        case 3:
            dayName = this.getString(R.string.dayWed);
            break;
        case 4:
            dayName = this.getString(R.string.dayThu);
            break;
        case 5:
            dayName = this.getString(R.string.dayFri);
            break;
        case 6:
            dayName = this.getString(R.string.daySat);
            break;
        default:
            dayName = this.getString(R.string.daySun);
            break;
        }

        final TextView dayText = (TextView) findViewById(R.id.dayName);
        final TextView editData = (TextView) findViewById(R.id.editData);
        final Button save = (Button) findViewById(R.id.buttonSave);
        final Button clear = (Button) findViewById(R.id.buttonClear);
        final String Day = dayName;

        dayText.setText(dayName);

        clear.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                editData.setText("");
            }
        });

        save.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String FILEOUTPUT = Day + ".txt";

                try {
                    String string = editData.getText().toString();

                    FileOutputStream fos = openFileOutput(FILEOUTPUT, Context.MODE_PRIVATE);
                    fos.write(string.getBytes());
                    fos.close();

                    Toast.makeText(ModifyInfo.this, "Saved", Toast.LENGTH_SHORT).show();
                } catch (IOException e) {
                    Toast.makeText(ModifyInfo.this, "Save error", Toast.LENGTH_SHORT).show();   
                }
            }
        });

        File FILEINPUT = new File(Day + ".txt");

        try {
            BufferedReader bfr = new BufferedReader(new FileReader(FILEINPUT));
            String line;

            while ((line = bfr.readLine()) != null)
            {
                editData.setText(line);
            }

            bfr.close();

        } catch (Exception e) {
            editData.setText("");
        }   
    }   
}

}

  • 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-23T23:52:56+00:00Added an answer on May 23, 2026 at 11:52 pm

    It is possible that android locks files from some folders and you can not modify them. You can use sharedpreferences or static objects.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.