Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:50:41+00:00 2026-05-26T09:50:41+00:00

i need to open a pdf file from my android app. I have the

  • 0

i need to open a pdf file from my android app. I have the pdf saved in the app package folder (/data/data/com.app.example/files). I have installed in the android emulator the adobe reader app. The problem is that when i try to open the pdf file with adobe reader the emulator shows me the next message: Invalid file path.

I don’t know why is this happening but i’m stuck on this point. The file is saved correctly, because i can open it in my computer.

Here is the code:

HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);
        try {
            HttpResponse response = client.execute(request);
            request(response, file_name);

            File file = new File("data/data/com.app.example/files/"+file_name);

            PackageManager packageManager = getPackageManager();
            Intent testIntent = new Intent(Intent.ACTION_VIEW);
            testIntent.setType("application/pdf");
            List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
            if(file.exists())
            {
                  if (list.size() > 0 && file.isFile()) {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_VIEW);
                        Uri uri = Uri.fromFile(file);
                        intent.setDataAndType(uri, "application/pdf");
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);     

                        startActivity(intent);
                  }else
                  {
                        System.out.println("NO APPs TO OPEN PDFs.");
                  }
            }
            else
            {
                  System.out.println("FILE DOES NOT EXIST.");
            }           
        }catch(Exception ex){
            System.out.println("Failed!");
            ex.printStackTrace();
        }


public String request(HttpResponse response, String file){
        String result = "";
        try{
            InputStream in = response.getEntity().getContent();
            FileOutputStream f = openFileOutput(file, MODE_WORLD_WRITEABLE);
            byte[] buffer = new byte[in.toString().length()];
            int len1 = 0;
            int counter = 0;
            while ((len1 = in.read(buffer)) > 0) {
                f.write(buffer, 0, len1);
                counter++;
            }
            f.close();
        }
        catch(Exception ex){
            result = "Error";
        }
        return result;
    }

Thanks in advance.

Regards, Javi.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:50:42+00:00Added an answer on May 26, 2026 at 9:50 am

    This is because the PDF file resides in your own package and Adobe reader trying to access PDF file from your package which is not allowed for Android application development.

    You can try to save file on SDCARD and then open it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i need to open pdf file.For that i have prepared code
I need to edit a specific page from a PDF file and I have
I need from my C# application open a PDF file by using Foxit Reader
I need to open a some types of files like .jpg, word, .pdf when
I need to Open a process (easy) and then somehow paste data from my
I need to create a pdf file from the HTML provided from database which
I have PDF file data in a SQL Server database, in the column type
In my Android app, I have various URLs that I access from a database
I need to export some data to an .XLS file, pdf, and print. I
I need to know how to read data from tabbed delimited text file in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.