title: How to save , read and write files in android in external storage?
body: <p>I'm trying to understand how to work with files in Android </p>
  
  <p>I have installed my android application in external storage </p>
  
  <p>it contain a folder  <code>data</code>of files that it need while running...</p>
  
  <p>firstly I think that my folder will saved automatically in the sdcard while installing </p>
  
  <p>but after reading some question here , It seem I should create a folder in which I save my </p>
  
  <p>folder <code>data</code>...</p>
  
  <p>I write this question to ask about steps to do to achieve my goal an I need your advances </p>
  
  <p><strong>Goal</strong></p>
  
  <ul>
  <li>Save a folder <code>data</code> in external storage , read from it and write a new file </li>
  </ul>
  
  <p><strong>Steps</strong></p>
  
  <ul>
  <li><p>add permission to manifest file </p></li>
  <li><p>create a folder in sdcard ==> how to place my folder there ?</p></li>
  <li><p>create a new file , save it on sdcard and write into it </p></li>
  </ul>
  
  <p><strong>code</strong></p>
  
  <p>This is a part of my activity :  </p>
  
  <pre><code>    {
        ....
         File file = new File ("...")
  
         doPrediction(file);
  
  
  }
  
  private void doPrediction (String FileName)
  
          {
  
       for (File child : VisualModels.listFiles()) {
  
  
       svmPredict.run(MyDataSource.inputPrediction,
  
           new File( MyDataSource.outputPrediction+ "/"+child.getName()+".predict"), 
  
           child);
            }
          }
  </code></pre>
  
  <p>I declared the class <code>svmPredict</code> as any ordinary java class ans this is the code of <code>run method</code></p>
  
  <pre><code>       try 
      {
          BufferedReader input = new BufferedReader(new FileReader(inputFile));
          DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
          svm_model model = new svm().svm_load_model(modelFile);
          if(predict_probability == 1)
          {
              if(svm.svm_check_probability_model(model)==0)
              {
                  System.err.print("Model does not support probabiliy estimates\n");
                  System.exit(1);
              }
          }
          else
          {
              if(svm.svm_check_probability_model(model)!=0)
              {
                  svm_predict.info("Model supports probability estimates, but disabled in prediction.\n");
              }
          }
          predict(input,output,model,predict_probability);
          input.close();
          output.close();
      } 
  </code></pre>