I know that the file is in Device Storage/WhatsApp/Media/WhatsApp Documents
and I want to read it (in fact there are many files there and I want to read any of them).
I am using Intent to get all pdf files.
In onActivityResult... if (resultCode == RESULT_OK) {
I am doing:
String FilePath = data.getData().getPath();
FilePath = FilePath.substring(FilePath.lastIndexOf('/') + 1).trim();
String path = this.getFilesDir().getAbsolutePath();
String alternatePath = "Device Storage\\WhatsApp\\Media\\WhatsApp Documents";
File file = new File( alternatePath+ "\\" + FilePath);
Next I am doing all the FileInputStream
etc stuff. But for some reason, it is giving filenotfound exception.
Please let me know where I am doing wrong.
P.S. the startactivityforresult part:
savebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
startActivityForResult(intent,PICKFILE_RESULT_CODE);
}
});