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
Related
From an Android app, I like to install an apk file from a web server. This apk file contains an update for the app.
All tutorials do this in two steps:
1 Download the file and save it to the phone's sd card memory.
2 Create a new Intent(Intent.ACTION_VIEW) and run the method setDataAndType(Uri.fromFile(new File(".... of this intent.
However, since Android Nougat, you get into trouble with permission to access the SD card memory. There are (complicated) solutions for this problem.
My question: is there a way to create an Intent, which gets a web URL as source for the apk file. Something like intent.setDataAndType(new URL("http://....")
This is easy for the programmer and it provides as clear interface from the program to the Android system
is there a way to create an Intent, which gets a web URL as source for the apk file. Something like intent.setDataAndType(new URL("http://....")
Not as part of standard Android. The app installer knows about the file scheme, and on Android 7.0+ it knows about the content scheme. It does not know about the http scheme.
All tutorials do this in two steps... Download the file and save it to the phone's sd card memory.
Few tutorials do that. Most download the file to external storage, which is not the same as removable storage. On Android 7.0+, you also have the option of downloading to internal storage and using FileProvider (or the equivalent) to make it available via a content Uri.
For my app I want to send the user a text file of data on an e-mail which they save in the download folder on their Android device.
The app will then pull the data from that file and use it in the app. In the desktop version URLLoader works fine with the file copied into the app source directory, but that method does not work on an Android device.
Storage permission is set.
I have tried using the Filestream method and manually copying the file into the app directory on the device, but that does not seem to work.
Ideally I want to be able to set path for the file to the device's download folder so that the user experience is as simple as it can be.
And before you ask, usage will be on wifi only tablets with questionable wifi access - sending e-mails with the file upfront is the only reliable way to handle this.
Thanks for any suggestions.
Adam
In mobile devices the File.applicationDirectory , is a read only folder, try to use File.applicationStorageDirectory
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#applicationDirectory
https://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4.html
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!!!
hello guys i need small help in understanding file system of android
Now in windows for example we create files using paths like "c:/mytextfile.txt" or "c:/folder/mytextfile.txt".Now how can i access files and folders in android i mean whats the path like.
Does the phone support file browser instead of relying on third party apps??
Android does not have a native file browser, but there are numerous third-party ones (Astro comes to mind). The filesystem of Android is that of Linux; the path separator is / and the FS grows from a single root called /. So, you have your app packages under /data/apps, and so forth. Unless the phone is jailbroken ("rooted"), you won't get to see the whole filesystem - permissions get in the way. This applies to all Android applications, they are sandboxed - that is, they don't get access the whole filesystem. There are API calls to get the path to the current application's sandbox directory.
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.