2012-04-25 58 views
3

在我的應用我創建的內部應用程序文件(數據/數據/包/文件),我想,當我使用此代碼閱讀這些文件能夠讀取PDF文件:如何從內部存儲器使用其他應用程序讀取pdf文件?

Uri path = Uri.fromFile(pdfFile); 
Intent pdfIntent = new Intent(Intent.ACTION_VIEW); 
pdfIntent.setDataAndType(path, "application/pdf"); 
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

我看了一下使用openOutputStream()方法,但我不知道如何閱讀他們通過this.Could任何人都可以幫助我?

編輯

pdfFile--

File directory=getFilesDir(); 
    pdfFile=new File(directory,filename+".pdf"); 
+0

也有相同的問題http://stackoverflow.com/questions/10299839/how-to-read-pdf-in-my-android-application – MAC 2012-04-25 09:05:17

+0

你的'pdfFile'字符串包含什麼? – Pallavi 2012-04-25 09:15:19

+0

@Plalavi - 文件目錄= getFilesDir(); \t pdfFile = new File(directory,filename +「。pdf」); – Navdroid 2012-04-25 09:57:40

回答

1

通行證MODE_WORLD_READABLEopenOutputStream()寫入PDF到內部存儲的時候。理論上,這將允許第三方應用程序讀取它。

或者對此文件執行ContentProvider,例如我在this sample project(此處將assets/複製到內部存儲器中)中演示的那個文件。

0

加入此項:
pdfFile.setReadable(true,false);

相關問題