title: Permission denied in android when create file
body: <p>I want to choose image from sdcard and encrypt them. i have some problem with java io exception - permission denied. i declared use permission in android manifest READ and WRITE EXTERNAL STORAGE but it doesn't work</p>
  
  <p><a href="https://i.stack.imgur.com/hCQ5N.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hCQ5N.jpg" alt="enter image description here"></a></p>
  
  <p>then I open Device File Explorer and check permission, all of them don't have permission write</p>
  
  <p>my code: </p>
  
  <pre><code>File file = new File(uri_result);//create path from uri
              final String[] split = file.getPath().split(":");//split the path.
              String filePath = split[2];
  
              try {
                  FileInputStream fis = new FileInputStream(filePath);
                  File fos_enc = new File( Environment.getExternalStorageDirectory().getAbsolutePath()+"/abcd.jpg");
                  fos_enc.createNewFile();
                  FileOutputStream fos = new FileOutputStream(fos_enc);
  
                  byte[] k = "123456".getBytes();
                  SecretKeySpec key = new SecretKeySpec(k,"DES");
                  Cipher enc = Cipher.getInstance("DES");
                  enc.init(Cipher.ENCRYPT_MODE, key);
                  CipherOutputStream cos = new CipherOutputStream(fos, enc);
                  byte[] buf = new byte[1024];
                  int read;
                  while ((read = fis.read(buf)) != -1) {
                      cos.write(buf,0,read);
                  }
                  fis.close();
                  fos.flush();
                  cos.close();
                  showAlertDialog("Encrypt Successfully");
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
              } catch (NoSuchPaddingException e) {
                  e.printStackTrace();
              } catch (NoSuchAlgorithmException e) {
                  e.printStackTrace();
              } catch (InvalidKeyException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>permission denied because the sdcard don't access write the file and i have no idea to resolve this. Hepl me please :)<br>
  fos_enc=newFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/abcd.jpg");</p>