IllegalArgumentException: File contains a path separator Android
I'm trying to write to an output file on my HTC One and get the following message in the LogCat: 11-21 08:05:18.228: W/System.err(6609): java.lang.IllegalArgumentException: File /storage/emulated/0/com.example.pattern1/myfile.txt contains a path separator The source code is given below: protected void writeToFile(String string){ File patternDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath().toString()+"/com.example.pattern1/myfile.txt"); patternDirectory.mkdirs(); FileOutputStream outputStream; try { outputStream = openFileOutput(patternDirectory.getAbsolutePath()