2012-02-09 13 views
1

私の資産フォルダにpdfファイルが置かれていますが、私はそれを読む意志を表明しています。私はこれを行うと、アップAPOPandroidのassetsフォルダに配置されたpdfファイルを読む

Uri path = Uri.parse("file:///android:asset/about.pdf"); 
    Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setDataAndType(path, "application/pdf"); 
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    startActivity(intent); 

は、Adobeリーダー を含むアプリケーションのリストが表示されますが、私はそれをクリックすると、ダイアログが言って表示されます: ここに私のコードである「エラー」を、ファイルパスではありません

有効

どのようにこの

+0

重複... http://stackoverflow.com/questions/3831019/how-to-read-a-pdf-in-android – himanshu

+0

私はこれを試しました - File file = new File( "file:/// android :asset/about.pdf "); – Ankit

+1

http://stackoverflow.com/questions/6491210/how-to-open-a-pdf-stored-either-in-res-raw-or-assets-folder –

答えて

1

を修正するにアプリの資産フォルダにこのファイルが私に教えてください?それがある場合は、あなたのURIが間違っている、この質問をチェックアウト:

How to open a pdf stored either in res/raw or assets folder?

あなたの資産の適切なURIを構築する方法を記述した答えがあります。