Note that there are some explanatory texts on larger screens.

plurals
  1. POOverwrite text file programmatically
    primarykey
    data
    text
    <p>I'm trying to overwrite a text file from android application, what I have done yet is,</p> <p>I have created one text file in one activity using:</p> <pre><code>FileOutputStream create_file = null; OutputStreamWriter osw = null; create_file = openFileOutput("filename.txt", Context.MODE_WORLD_WRITEABLE); osw = new OutputStreamWriter(create_file); osw.write("text goes here"); osw.close(); create_file.close(); </code></pre> <p>and I have opened that file in another activity read the contents line by line using:</p> <pre><code>FileInputStream open_file = openFileInput("filename.txt"); InputStreamReader isr = new InputStreamReader(open_file); BufferedReader inRd = new BufferedReader(isr); while ((getText = inRd.readLine()) != null) { Toast.makeText(getApplicationContext(), getText, Toast.LENGTH_SHORT).show(); } </code></pre> <p>through this I have verified whether the content is stored or not, and made sure that the file exist with the content, but when I try to overwrite that file from another activity using:</p> <pre><code>FileOutputStream create_file = null; OutputStreamWriter osw = null; create_file = new FileOutputStream(new File(PasswordUtil.pswrd_file), false); osw = new OutputStreamWriter(create_file); osw.write(getString); </code></pre> <p>I'm getting one exception,</p> <blockquote> <p><code>java.io.FileNotFoundException:/ filename.txt (Read-only file system)</code></p> </blockquote> <p>Note: The text file is stored in Internal storage.</p> <p>Any help, thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload