title: File Not Created in Android P
body: <p>I am creating <code>File</code>. Its working in all versions except Pie Version. This is my code. </p>
  
  <pre><code>private void writeToFile(String data, Context context) {
      try {
           File file = new File(Environment.getExternalStorageDirectory() + File.separator + "testApp.txt");
          if (!file.exists()) {
              file.createNewFile();
          }
  
          FileWriter writer = new FileWriter(file);
          writer.append(data);
          writer.flush();
          writer.close();
      } catch (IOException e) {
          Log.e("Exception", "File write failed: " + e.toString());
      }
  }
  </code></pre>