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

  • Home
  • SEARCH
  • 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 6867959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:22:28+00:00 2026-05-27T03:22:28+00:00

How come every time i try to open a pdf file in my SDCARD

  • 0

How come every time i try to open a pdf file in my SDCARD using the following code, it doesn’t actually open the pdf file itself, but goes into the menu of adobe reader? Is there anything wrong with my code?

Intent intent = new Intent();
    File pdfFile = new File("/sdcard/sample.pdf");
    Uri path = Uri.fromFile(pdfFile);
    intent.setAction(Intent.ACTION_VIEW); 
    intent.setData(path);
    intent.setType("application/pdf");
    intent.setPackage("com.adobe.reader");
    startActivity(intent);
  • 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-27T03:22:28+00:00Added an answer on May 27, 2026 at 3:22 am

    No, there’s nothing wrong. You’ve set the type to pdf and specified the package as adobe.reader. What that does is fire off an intent to launch the pdf in adobe reader. There’s no way to display a pdf directly in your app without using a library (or writing code yourself) to render PDFs and display them.

    Note that if you only set the type and not the package, the system will find whatever app is available to display PDFs

    EDIT

    You can try something like

        Intent intent = new Intent(Intent.ACTION_VIEW);
        File file = new File( filename  );
        intent.setDataAndType( Uri.fromFile( file ), "application/pdf" );
        startActivity(intent);
    

    or

            Intent intent = new Intent();
            intent.setPackage("com.adobe.reader");
            intent.setDataAndType(Uri.fromFile(file), "application/pdf");
            startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Every time I try to do something seemingly-simple in CSS, it doesn't work. I
Every time I try to run a Wizard in Access 2007 a dialog box
I trying to use the Open Session in View pattern, but everytime I try
How come every object appears to be marked new, instead of just objects that
This is a problem I come across every so often; I always end up
Every solution I come up with is not thread save. def uuid(cls,db): u =
Come across what looks at first sight like an MT-issue, but I'm trying to
I am reading the book Facebook Platform Development in order to try to code
I'm trying to learn how to use managed/unmanaged code interop, but I've hit a
I have an OpenLayers/GeoExtJS map that I have a WMSGetFeatureInfo popup come up every

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.