Error: The document path is not valid
I want to store pdf in internal storage and after I want to read It.
I seen many que in this site but none help me out.
My code working file in Environment.getExternalStorageDirectory() now I used getCacheDir() for internal storage.
for write pdf
FileOutputStream fos = new FileOutputStream(file);
fos.write(baf.toByteArray());
fos.close();
file write is completed , I can see file in cache folder.
for read pdf
file = new File(getCacheDir()+ File.separator+fileName);
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0 && file.isFile()) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
I got error "The documenty path is not valid"