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 7569971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:18:01+00:00 2026-05-30T15:18:01+00:00

now I am doing an Android application.I have to read a file from sdcard.I

  • 0

now I am doing an Android application.I have to read a file from sdcard.I installed adobe reader in my emulater.And i used the following code to run the file from sdcard.

intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("/sdcard/samp.pdf"), "application/pdf");
    try{

        startActivity(intent);
    }
    catch (ActivityNotFoundException e) {
        System.out.println("5");
        // No application to view, ask to download one
        System.out.println("hai");
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("No Application Found");
        builder.setMessage("Download one from Android Market?");
        builder.setPositiveButton("Yes, Please",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Intent marketIntent = new Intent(Intent.ACTION_VIEW);
                        marketIntent
                                .setData(Uri
                                        .parse("market://details?id=com.adobe.reader"));
                        startActivity(marketIntent);
                    }
                });
        builder.setNegativeButton("No, Thanks", null);
        builder.create().show();
    }

I inserted a pdf named sample.pdf in sdcard.But when I am running my application I am getting “the file could not be opened”. But i can open the pdf manually from the emulater.Please help me to find out a solution.

Hi friends I got the solution. I removed
intent.setDataAndType(Uri.parse("/sdcard/samp.pdf"), "application/pdf");
and add

 File file = new File("/sdcard/sample.pdf");
    Uri uri = Uri.fromFile(file);
    intent.setDataAndType(uri, "application/pdf");

now its working. But now I put the sample.pdf folder in my assets folder and write the following code.

 File file = new File("android.resource://com.pdftest/assets/sample");
    Uri uri = Uri.fromFile(file);
    intent.setDataAndType(uri, "application/pdf"); 

and I getting file path not valid message…

  • 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-30T15:18:02+00:00Added an answer on May 30, 2026 at 3:18 pm

    The Uri must contain more than just the path. If you look at the content of your Uri, it is empty. To have a proper Uri, use Uri.fromFile()

    file = new File(Environment.getExternalStorageDirectory()+"/samp.pdf");
    if (file.exists())
    {
      Uri uri = Uri.fromFile(file);
      intent.setDataAndType(uri, "application/pdf");
      startActivity(intent);
    }
    else
    {
    Log.e("File not Exist","Check pdf File");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have android application that is written regular way. layouts, java, APK. Now, depending
So I'm making this android application, that needs to read data from user-provided CSV
I am developing an android application in which I have to upload image from
I want to have my application periodically save a zip file to the cloud.
I need help in upgrading apk file. I have apk file developed for android
So I was doing this comparative study between the application security model between android
I've programmed a client-server application for Android and I'm doing the same for Iphone.
For an Android application, I have implemented an external function in C, which I
The set-up: I have an android application that so far can register a user
I have an Android application in which I'm trying to parse a small sized

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.