title: read and write files to removable sd card
body: <p>How to read and write files to removable sd card in Android?</p>
  
  <p>I want to store Android Id in Text file. The text file should be created on external sdcard.</p>
  
  <p>Code:</p>
  
  <pre><code>PackageManager m = getPackageManager();
  String s = getPackageName();
  PackageInfo p = m.getPackageInfo(s, 0);
  s = p.applicationInfo.dataDir;
  File myFile = new File(s + "/MyDoople.txt");
  myFile.createNewFile();
  FileOutputStream fOut = new FileOutputStream(myFile);
  OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
  myOutWriter.append(TxtS.getText());
  myOutWriter.close();
  fOut.close();
  Toast.makeText(getBaseContext(),"Text Updated",Toast.LENGTH_SHORT).show();
  </code></pre>
  
  <p>The Second is</p>
  
  <pre><code> File sdCard = new File("file:///mnt/external_sd/");
   File myFile = new File(sdCard, "test.txt");
   FileWriter writer = new FileWriter(myFile); 
   writer.append(TESTSTRING);
   writer.flush(); 
   writer.close();
  </code></pre>