title: android, adb, no such file or directory
body: <p>I am having problems accessing the files I have created in my application.
  Have went through all the possible suggestions in the internet and I still can't access the files.</p>
  
  <ul>
  <li>I am using rooted phone</li>
  <li>I am writing files to External Storage on Samsung Galaxy Nexus</li>
  <li>DDMS sees the created files but whenever I try to pull them it shows me:</li>
  </ul>
  
  <blockquote>
    <p>[2013-06-25 11:45:26 - ddms] transfer error: No such file or directory</p>
    
    <p>[2013-06-25 11:45:26] Failed to pull selection: No such file or directory</p>
  </blockquote>
  
  <p>However, the files are visible in DDMS, and yes I have tried both selecting the phone, and the package in the Devices explorer on the left side</p>
  
  <p>When I open the adb shell as a root:</p>
  
  <blockquote>
    <p>su</p>
    
    <p>cd storage/sdcard0</p>
  </blockquote>
  
  <p>then I entered both</p>
  
  <blockquote>
    <p>chmod 777 myPackage</p>
  </blockquote>
  
  <p>and</p>
  
  <p>chmod -R 777 myPackage</p>
  
  <p>but still it does not change the permissions for the files that I have written into this directory. Also chmod 777 directly on a file in a myPackage directory does not work and returns : No such a file or directory.</p>
  
  <p>Needless to say that I cannot pull the files from above the shell.</p>
  
  <p>Here's the code I'm using to generate the files.</p>
  
  <pre><code>protected void onHandleIntent(Intent arg0) {
  
      ArrayList&lt;String&gt; parameters = new ArrayList&lt;String&gt;();
  
      String fileName;
      File file;
      File parameterFile;
  
      //generate data containing general information about the device
      //retrieve the data from the intent
  
      parameters=arg0.getStringArrayListExtra("com.example.mypackage.parameters");
      for(int i = 0; i &lt; parameters.size(); ++i)
      {
          parameter = parameters.get(i);
          String[] split = parameter.split(" ");
          String name=split[1];
          fileName = name + ".csv";
  
          //check the state of the external storage
          String state = Environment.getExternalStorageState();
          Log.e("DIR: ", "STATE: " + Environment.getExternalStorageState());
          //return info if the storage is read-only
          if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
          {Log.e("DIR: ", "STATE: READ_ONLY");}
  
          final File parametersDir = new File(Environment.getExternalStoragePublicDirectory("myPackage"), "Parameters");
          parametersDir.mkdirs();
  
          parameterFile = new File(parametersDir, fileName);
          parameterFile.setExecutable(true);
          generateTextFile(parameterFile, parameter);
  
          //check file's permissions
          parameterFile.setExecutable(true, false); 
          parameterFile.setReadable(true, false);
          parameterFile.setWritable(true, false);
  
          boolean executable = parameterFile.canExecute();
          boolean readable = parameterFile.canRead();
          boolean writable = parameterFile.canWrite();
  
          if(!executable){Log.e("FILE: ", "File cannnot be executed.");}
          if(!readable){Log.e("FILE: ", "File cannnot be read.");}
          if(!writable){Log.e("FILE: ", "File cannnot be written to.");}
  
          }
  </code></pre>
  
  <p>and here's the method I am using to generate the files</p>
  
  <pre><code>private void generateTextFile(File file, String string)
     {    
          try {                   
              FileOutputStream stream = new FileOutputStream(file);
  
              try{
                  FileWriter writer = new FileWriter(file);
                  writer.append(string);
                  writer.flush();
                  writer.close();
  
                  String path = file.getPath();
                  Log.e("Directory: ", path);
  
              } 
  
              catch (IOException e) 
              {
                  Log.e("FILE: ", "Cannot create filewriter. Writer problem.");
              }
  
              finally 
              {
                  stream.getFD().sync();
                  stream.flush();
                  stream.close();
              }
  
          }    
          catch(IOException e)
  
          {
              Log.e("FILE: ", "Cannot write to file. Stream problem.");
          }
     }
  </code></pre>
  
  <p>according to log, once my files are written, even though I am setting them to readable, writable and executable, their permissions are still unchanged</p>
  
  <p>to clear the doubts, i also have declared in the manifest</p>
  
  <blockquote>
    <p>uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"</p>
    
    <p>uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"</p>
  </blockquote>
  
  <p>I got to the point that I really have no idea what to do next, so I would be very glad if anyone could help.</p>