in my application, user downloads any ebook format file from the web site and i need to handle that downloaded file in my code for the purpose of -Enable the user to view the ebook in a android device.
how to get control of a file after downloaded in to sdcard
how to change its file extension and file content
i found following answers:
we can use file handling Technic to move ,copy etc
to know its MIME type we can use setOnDownloadListner.
Related
I'm developing a android application which is downloading contents from a API as a zip file and extract it in to the assets folder in the app.Then using the web view in the app can load that content.
How can i prevent user from directly access the extracted folders (using file manager) and only allow user to access the folders via the application?
I found the answer from the below mentioned blogs .
to save my html files -
saving file in internal storage android
And to load-
http://fixabc.xyz/question/14624567/load-somefile-html-file-from-internal-storage-to-a-webview-of-an-app
Thank you Stackoverflow!!!
When the user downloads an attachment/file from Chrome from Gmail, whatever
I need the file to be downloaded to a specific defined directory.
I try to be more clear: I need to create an app that contains the files that are downloaded.
Therefore the app will define a directory.
When the user downloads something from internet, Gmail.. the download should go in there.
I do not know how to implement this kind of behavior.
If you don't want the DownloadManager to put your file outside of your app or on external storage. You may have to handle the download requests yourself and just write the file out into a download directory within your apps data directory. This question has an example of how to get the OutpustStream of the connection and write out the file. Hope this helps.
Android:How to download the File from the server and save it in specific folder in sdcard.
In my application i need to open pdf file.For that i have prepared code to open pdf file.Suppose my pdf file in sdcard, It is working fine.when my application change from sdcard to application path i.e /data/data/app.package/ it is not working.I got alert dialog like
Invalid file path .Please guide me to over some this problem.
/data/data/app.package/ is package private. To share this pdf you'd probably have to move it to external storage (you can use getExternalFilesDir()). This directory has no security enforced.
You must make /data/data/app.package/file.pdf redable for other applications.
1) using openFileOutput(fname, Context.MODE_WORLD_READABLE).close(); create share file in your app data directory.
2) write pdf file to created file using Streams (you may write to stream returnet by openFileOutput instead of close it)
3) open your pdf file
i was researching on how to download a file to the native filesystem via a URL with phonegap. I then read about this method:
http://docs.phonegap.com/en/1.4.1/phonegap_file_file.md.html#FileTransfer_download
It should allow one to save files directly via a URL to the device. But it needs a specified target where to save the file.
target - Full path of the file on the device
What would be best practise to choose here, so the file does not just get hidden in some folder, but is accessible. What differences are there between android and ios (maybe also windows phone) ?
TL;DR: where to save downloaded file with phonegap?
Thanks in advance!
here is a list of mobile paths from the w3c standard:
http://wiki.phonegap.com/w/page/35605874/Planning%3A%20File%20API
and here is how you use it with phonegap:
http://docs.phonegap.com/en/1.4.1/phonegap_file_file.md.html#LocalFileSystem
so you have to request the file system
onSuccess you can use the path
here a full example: Writing and reading file in phonegap
I'm having an Android Ftp Client, I download different types of files (.txt , .pdf , .mp3) from the server. And then I list all the files I downloaded.
So my questions are as follows:
If the file is on the SD card & I listed the files by their names. What I want to do is that by clicking on the name the file is opened.
Meaning if the file name is "test.pdf" & I clicked on it it should be opened in the same way the pdf file is opened in the pdf viewer, Same thing goes for mp3 files for example, by clicking on the file I want it to be played.
Thanks alot for the help in advance
Create an ACTION_VIEW Intent, using Uri.fromFile() for the Uri, and with a MIME type suitable for the type of content (e.g., you might decide to use application/pdf for .pdf files). Then, call startActivity() on that Intent.
There may be an open source Android file manager app that you could examine to see how they approach it.