Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just thought I would update with at least a partial answer. At least some of my issue has to do with testing in debug mode on my Razr Maxx. When I am connected via USB debugging then the call to create a new file fails as follows:</p> <p>06-06 10:04:30.512: W/System.err(2583): java.io.IOException: open failed: EACCES (Permission denied) 06-06 10:04:30.512: W/System.err(2583): at java.io.File.createNewFile(File.java:940)</p> <p>When I am running the app standalone on my device or in an emulator then it all works as expected. Not sure if this is related specifically to Razr Maxx or some other issue?</p> <p>My code that is working is (from: <a href="https://stackoverflow.com/questions/8330276/write-a-file-in-external-storage-in-android">Write a file in external storage in Android</a>) :</p> <pre><code>private void writeToSDFile(){ // Find the root of the external storage. // See http://developer.android.com/guide/topics/data/data- storage.html#filesExternal File root = android.os.Environment.getExternalStorageDirectory(); mStatusTV.append("\nExternal file system root: "+root); // See https://stackoverflow.com/questions/3551821/android-write-to-sd-card-folder File dir = new File (root.getAbsolutePath() + "/download"); dir.mkdirs(); File file = new File(dir, "myData.txt"); try { file.createNewFile(); FileOutputStream f = new FileOutputStream(file); PrintWriter pw = new PrintWriter(f); pw.println("Hi , How are you"); pw.println("Hello"); pw.flush(); pw.close(); f.close(); } catch (FileNotFoundException e) { e.printStackTrace(); Log.i(TAG, "******* File not found. Did you" + " add a WRITE_EXTERNAL_STORAGE permission to the manifest?"); mStatusTV.append("Write File 1: " + e.getMessage()); } catch (IOException e) { e.printStackTrace(); mStatusTV.append("Write File 2: " + e.getMessage()); } mStatusTV.append("\n\nFile written to "+file); } </code></pre>
 

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