How to open local pdf file in android?

I need to show the local pdf file in my Android application, this pdf file should be included in my application package, I have this, but I don’t know how to build the class File.

public void loadreglamento(View v){
        //Im supposed to give a path with the file but I really dont know how
        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(path, "application/pdf");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

    }

This code is suitable for me, I do not care if the user sees the document in an external editor / editor.

I also need to know where I need to copy the PDF file.

Thanks in advance.

+4
source share
1 answer

First answer your question: "How to create a File class?"

The following is a simple example.

File myFile = new File("Your any type of file url");

Android Developer File, .

URL- PDF. PDF , , URL-.

:

  • . , , .

  • : , Asset Manager.

Assets.

PDF , PDF.

, , PDF Assets - SD-Card , . PDF , Sunil at Stack Overflow:

pdf

, . .

0

All Articles