I am making an app that must work offline. So, I need the users to open and download pdf from the app without any internet. The pdf should be in the app already when the user opens it.
How can I do this?
I have seen many tutorials but have become more confused.
P.S Dont want to pay for extensions
Thankyou. I have seen this in the previous discussion but I am still not sure if this allows me to output the file .. the user only reads and downloads it.. is it possible through this code ?
Appreciate the response
P.s. please note that I cannot use pdf web viewer as offline use is intended
Output the file ? To where ?
You would use different methods for that
Sorry if use of words is wrong.
The function should be so:
The user clicks a button and a pdf opens .. (it will not be available on device of user before he clicks the button) ..after pdf opens .. if user will, it can be downloaded.
All this must happen without use of internet..
Thanks and best reagrds
How will this work ?
To where? The pdf is already on the app, you want to copy the file to some form of shared storage on their device ? For what purpose ?
It must be available/present on the device. However, it can be in the internal storage, so it is not accessible / visible to the user without root access.
Ok so let me explain why I am doing this. So for my project there is a list of emergency contacts.. there are multiple emergency contact lists for multiple departments. The lists are in pdf form.
My company has asked me to put those pdfs in the app.
The user simply needs to open the app and go the relevant list and download it..
Lets say I have 5 different pdfs. They are stored in the app.
They are not available to the user until the user goes to the app and clicks on the button
Where?
Again, I ask, why does the user need to "download" one or any of the pdfs? They can view them in the app.
By "download" I am still assuming that you mean copy the pdf file to somewhere on their device....
Thankyou so much anke for your response..
But how? The pdf is shared through the app.. the user doesn't have it before he/she/it/they opens the app
and if user already has the file.. I wont need to give it to him/her/it/they. This is something I don't understand in other discussions as well, what is the point of sharing a file the user already has on its device..
yes , copy it somewhere on their device is the correct way to formulate this.. I am sorry for the use of word download
So .. to summarise
user must be able to view it on app and also copy it on their device
If the pdf files are in your assets (media folder) use the File component to copy the files to a [edit] writeable/readable location on the device. @Anke is the expert on this
through media I can upload the file. I mean i see it , like i can upload image.. the same way i can upload pdf. so I am assuming thats how to upload data to the app or I am wrong?
In assets.
Ok that sounds cool, we are on the same page now I guess, thanks for your time @Anke I hope my query is now clear? your help will be greatly appreciated
Copy the PDF file to one of the Shared
folders (/Download
or /Documents
) using the File
component or one of the File
extensions (from @Taifun or @vknow360 to avoid storage permissions on Android 11+).
Then the user has access to it and can open it without using your app.
Or you might want to share it using the Sharing component ... (?)
Ok, I will try these approaches. I hope it works. If it doesn't i will inform here.
Thanks for your time and support.
hello @Anke i really cant seem to get my code working, can you refer me to some sample codes.
Also I don't understand where exactly to access the extensions from of the 2 people you mentioned? Thanks and best regards!
Show your blocks.