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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:44:00+00:00 2026-06-13T22:44:00+00:00

Im trying to use Adobe reader to read pdf files downloaded from the server

  • 0

Im trying to use Adobe reader to read pdf files downloaded from the server the problem is When i store it in the internal storage Other application can’t read the file. Now i Want to know how can i Copy this file in the external storage(/sdcard/) so it can be viewed by pdf viewers.

Due to security reason I’m storing the files in the Internal Storage and would delete the one in external storage afterwards.

My question is How can i copy the file saved in the internal storage without using the raw or the assets to put in the inputstream.

    InputStream myInput = getResources().openRawResource(R.raw.p13);

        FileOutputStream fos = openFileOutput("sample", Context.MODE_PRIVATE);

        // transfer bytes from the input file to the output file
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer)) > 0)
        {
            fos.write(buffer, 0, length);
        }
        // Close the streams
        fos.flush();
        fos.close();
        myInput.close();
  • 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-06-13T22:44:02+00:00Added an answer on June 13, 2026 at 10:44 pm

    at which path you are storing the pdf file ?

    See below one to get file from android Assets and copy it to the specific sdcard location.

    I will first check for the pdf file whether it is already available at desire path or not.

     File file1 = new File("/sdcard/SampleProjectApp/WindsorONE_Mobile_Molding.pdf");
        File file2 = new File("/sdcard/SampleProjectApp/WindsorONE_Mobile_PK.pdf");
        File file3 = new File("/sdcard/SampleProjectApp/Alone.mp4");
    
        if(!((file1.exists())) || !((file2.exists())) || !((file3.exists()))) {
            ArrayList<String> files = new ArrayList<String>();
            files.add("WindsorONE_Mobile_Molding.pdf");         
            files.add("WindsorONE_Mobile_PK.pdf"); 
            files.add("Alone.mp4");
            new myAsyncTask().execute(files);
        }
    

    Now, if the file is not present at that position then it will execute the myAsyncTask to copy file from assets to the SdCard.

     // AsyncTass for the Progress Dialog and to do Background Process
    private class myAsyncTask extends AsyncTask<ArrayList<String>, Void, Void> {         
        ArrayList<String> files;         
        ProgressDialog dialog;         
        @Override         
        protected void onPreExecute() {             
            dialog = ProgressDialog.show(ListSample.this, "W1 SALES (beta)", "Loading...");         
        }         
        @Override         
        protected Void doInBackground(ArrayList<String>... params) {              
            files = params[0];             
            for (int i = 0; i < files.size(); i++) {                 
                copyFileFromAssetsToSDCard(files.get(i));                
            }             return null;         
        }         
        @Override         
        protected void onPostExecute(Void result) {             
            dialog.dismiss();         
        }      
    } 
    
    
    
     // Function to copy file from Assets to the SDCard
    public void copyFileFromAssetsToSDCard(String fileFromAssets){
        AssetManager is = this.getAssets();
        InputStream fis;
        try {
    
            fis = is.open(fileFromAssets);
            FileOutputStream fos;
            if (!APP_FILE_PATH.exists()) {
                APP_FILE_PATH.mkdirs();
            }
            fos = new FileOutputStream(new File(Environment.getExternalStorageDirectory()+"/SampleProjectApp", fileFromAssets));
            byte[] b = new byte[8];
            int i;
            while ((i = fis.read(b)) != -1) {
                fos.write(b, 0, i);
            }
            fos.flush();
            fos.close();
            fis.close();
        } 
        catch (IOException e1) {
            e1.printStackTrace();
        }
    }
    

    Updated

    For your part:

    replace
    SampleProjectApp/WindsorONE_Mobile_Molding.pdf

    with

    Android/data/com.project.projectname/cache/YOUR_PDF_FILE.pdf

    Hope it make sense.

    Updated 2

    Below code is copy file from one path to another path. You simply have to pass the path of the file where it is exist and the path where it has to be copy.

    Code:

    public static boolean copyFile(String from, String to) {
    try {
        int bytesum = 0;
        int byteread = 0;
        File oldfile = new File(from);
        if (oldfile.exists()) {
            InputStream inStream = new FileInputStream(from);
            FileOutputStream fs = new FileOutputStream(to);
            byte[] buffer = new byte[1444];
            while ((byteread = inStream.read(buffer)) != -1) {
                bytesum += byteread;
                fs.write(buffer, 0, byteread);
            }
            inStream.close();
            fs.close();
        }
        return true;
    } catch (Exception e) {
        return false;
    }
    

    }

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

Sidebar

Related Questions

I am trying to use Adobe IFilter to search PDF files. My code is
I'm trying to find percise coordinates from a path in Adobe Illustrator to use
I'm trying to save a dynamic pdf file generated from a web server using
I am trying to use URLLoader to load an XML file from server (same
I´m trying to parse a LinearGradientBrush from Xaml strings, without any problem I use
i'm trying use facebook API to upload photo in my fan page. I downloaded
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use Powershell to script the removal of specific custom errors from an
I'm trying to use a RESTful web service in Adobe AIR. The service uses

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.