English 中文(简体)
页: 1
原标题:passing pdf from assets to sdcard
  • 时间:2012-05-07 13:51:12
  •  标签:
  • android

i m 试图从我的 raw子上通过card子,以示意。

在我宣布开幕时,我向我说,国防军已经瘫痪。 既然我对上游如何运作并不抱着很大的压力,我认为这个问题来自那里。

final String extStorageDirectory = Environment
                        .getExternalStorageDirectory().toString();
                final String festivalDirectory_path = extStorageDirectory
                        + Constants.PDF_STORAGE_PATH;
                File pdfOutputFile = new File(festivalDirectory_path, "/");
                if (pdfOutputFile.exists() == false) {
                    pdfOutputFile.mkdirs();
                }
                File pdfFile = new File(pdfOutputFile, nameOfThePdf);

                try {
                    InputStream in = getResources().openRawResource(R.raw.blablublo);

                    FileOutputStream out = new FileOutputStream(pdfFile);
                    byte[] buffer = new byte[1024];
                    int bufferLength = 0;
                    while ((bufferLength = in.read(buffer)) > 0) {
                        out.write(buffer, 0, bufferLength);
                    }
                    out.close();
                } catch (Exception e) {
                    Log.e("tag", e.getMessage());
                }
                Uri path = Uri.fromFile(pdfFile);
//              Uri path = Uri.parse(Constants.SPLASH_URI + R.raw.cartecannotpdf);
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(path, "application/pdf");
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);

希望有人能帮助我!

th

Renaud

最佳回答

好像你们的解决办法已经结束一半。

InputStream contentStream = PropertyManager. open(“cartecanotpdf.pdf”); - Creats a stream which You can use to Read all the data from the PDF file in the assets rafter.

File file = new file(dir, “cartecannotpdf”); - 这只是与将档案存放在SDCARD的一个地点建立了联系。

你再次失踪的Teh部分实际上是从投入流中复制的。 目前,SDCARD的档案要么没有经验,要么只是空壳(没有数据),因此你的意图将抱怨它腐败。

Here is a QA that has a full solution for you. How to copy files from assets folder to sdcard?

Edit: 此外,我不相信你是否需要把档案放在你的资产中,或者如果你能够把档案留在你的妇女、妇女、和平与安全部的手里。 我总是用手法处理档案。 在你叫作资产管理时,确保你实际上拿到档案。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签