我在模擬器裡保留了一份pdf文件,並且安裝過**adobe reader**。我試過用下面的代碼讀取模擬器的pdf文件
代碼:
File file =
new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/iTunes Connect.pdf");
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path,"application/pdf");
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(xv.this,
getString(R.string.app_name),
Toast.LENGTH_SHORT).show();
}
但是報出:file path is not valid
怎麼解決?
new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/iTunes\\ Connect.pdf");