title: Editing existing file in Android
body: <p>I am trying to edit existing file on the device by-First- select the file using selector that retrieve the path of the file like this "mnt/sdcard/file.png". Then I pass it to reader to read the existing file then modify it by by shifting the Ascii of every char. Then Overwrite it again to replace the old one. </p>
  
  <p>I have tested the code on a desktop app on PC files and it Works perfect, but does not work as an Android app. It worked on my device once but did not work again</p>
  
  <p>About what I did:</p>
  
  <p>1)Add writing on External source Permission in the Mainafest file
  2)Select the file right and retrieve it path
  3)Read the file content true</p>
  
  <pre><code>        File file = f;
          FileInputStream fin;
          fin = new FileInputStream(file);
          byte fileContent[] = new byte[(int)file.length()];
          fin.read(fileContent);
  </code></pre>
  
  <p>4)Modify the file bytes
  5)Write back (Overwrite) in the original file</p>
  
  <pre><code>        FileOutputStream fos = new FileOutputStream(f.getAbsolutePath());
          fos.write(enc_msg);
          fos.write((byte)seed);
          fin.close();
          fos.close();
  </code></pre>
  
  <p>6)Set the file to null again
  7)Call finish() in the onClickListner</p>
  
  <p>Thanks in Advance</p>