Я пытаюсь зашифровать PDF с паролем.даже когда файл PDF присутствует в хранилище, его файл показа отсутствует.путь тоже правильный.Я включил разрешение на чтение и запись также
private void Write() {
// Need to ask for write permissions on SDK 23 and up, this is ignored on older versions
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,
new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
}
}
public void file_manager(View view) {
myfileintent = new Intent(Intent.ACTION_GET_CONTENT);
myfileintent.setType("*/*");
startActivityForResult(myfileintent, 10);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
switch (requestCode) {
case 10:
path = data.getData().getPath();
akhil = new File(path);
break;
}
}
public void encrypt(View v){
try {
encryptPdf(Environment.getExternalStorageDirectory().getAbsolutePath()+path,path);
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
public void encryptPdf(String src, String dest) throws IOException, DocumentException {
File z=new File(src);
Toast.makeText(this, src, Toast.LENGTH_SHORT).show();
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
stamper.setEncryption(USER, OWNER,
PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
stamper.close();
reader.close();
}
Запуск в Android Studio показывает это
W / System.err: java.io.IOException: / storage / emulated / 0 /external_files / Download / 1484820337WBJEE Образец математического документа 2.pdf не найден как файл или ресурс.