모바일 내부 메모리에 저장된 PDF 파일을 열려고합니다 ... 파일 경로를 Uri에 전달하려고합니다. 나에게이 오류 을 보여주는 것은)내부 메모리에 저장된 PDF 읽기 (파일 경로가 유효하지 않음)
targetFile.exists의
targetFile=new File("/data/data/package Name/app_mydir/test.pdf");
}
Intent intent;
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(targetFile), "application/pdf");
startActivity(intent);
파일 저장 방법은 무엇입니까? 일반적으로 데이터 파일은 루트가 아니라 앱 디렉토리의 "files"폴더에 있습니다. – FoamyGuy
나는 이것을 사용하고있다 디렉토리 = getBaseContext(). getDir ("mydir", Context.MODE_PRIVATE); \t \t \t \t \t file file1 = new File (directory, PdfName); – Reham
"getBaseContext()"를 "YourActivityName.this"로 바꿉니다. 또한 파일을 다른 응용 프로그램에 전달하려고하면 MODE_PRIVATE를 사용할 수 없습니다. – FoamyGuy