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();
you can use this method
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.
Now, if the file is not present at that position then it will execute the myAsyncTask to copy file from assets to the SdCard.
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:
}