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
Related
When I download a pdf file from the Android app, I do not want the user to be able to find it on the phone. Is there such a hidden space on Android phones? I have tried putting a dot in the folder or trying other solutions from the internet but they can reach the windows computers when the phone is connected to the computer via cable. Is there anyone who can suggest a solution?
You should avoid having that file on the external storage completely.
Simply use getFilesDir() for that.
Use the device's internal storage as described in the android docs.
Files stored on the internal storage are only visible to your app and removed when your app is uninstalled.
Source: https://developer.android.com/training/basics/data-storage/files.html
I am using Phonegap to create a html 5 app and I would like to be able to download a file from the internet, and store it in the same directory as the app is in.
So, my app will open index.html, and in that folder the file needs to be saved.
After that, it needs to check if it has internet connection, and if not, it needs to open the file I just downloaded.
How can I do this?
I believe that if you just download it, it will go in the default download map.
Also Will there be a difference when downloading/saving this file on an android or iOs device?
I would like to be able to download a file from the internet, and store it in the same directory as the app is in.
The install location of the application is unavailable for writing in most of the platforms due to security.
However, you can write to a persistent location using the File API.
it needs to check if it has internet connection, and if not, it needs to open the file I just downloaded. How can I do this?
There are two parts to this, first is the check for internet connection, which can be accomplished using the Connection object. The latter part can again be done using the File API.
I want to password protect my local phone directory folder
This folder (directory) has been created by my application at run time with password protection.
My application can open this folder and used for self.
Any one can't open this folder manually. It is possible in android.
Thanks in advance.
This is not possible on Android.
You could create your folder on the internal memory, so that only your app can access it on normal devices. However, anyone with a rooted device will be able to browse your folder using a file manager, and other apps will also be able to read its contents if given root access.
A folder on the external storage is accessible to all apps with the READ_EXTERNAL_STORAGE permission, so you'll want to avoid using that.
At any rate, there is no 100% effective way to secure your folder such that only your app can access it.
However, you could try encrypting your data. This is what many apps like whatsapp do. Even when Whatsapp backs up the chats to the external storage, it is AES encrypted so that while others can access the data, they can't read it without decrypting it first. I would recommend that your try encryption
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 want to decouple data from code on my Android application, and I am not sure of the best way to do that.
For instance - with the Linux Mahjongg game you can add new tiles to the game by dropping a specially formatted file into a specific directory. The Mahjongg game checks that directory when it starts up.
I want to do the same thing with my Android app - I want to be able to install the app, and then have separate installs for different data files. It's the data file installs that have me hung up. I do not want to have to set up my own server and write my own download code.
You can ship the data with the installer app, then use Input/Output Streams to copy the data from the assets or raw dirs.
Check this out:
Ship an application with a database
The answer has an implementation of in/outputstream. You don't need to use a db, just copy the file to ext storage.
One important detail: if you put the file in assets, it will be shipped compressed, and the phone/tab will try to uncompress the file in its entirety in memory. One (hocky) way to avoid that is to name the file .mp3. Assets in .mp3 format are not compressed. (Hey! I said it was hocky!)
The installer app can either uninstall itself by using ACTION_DELETE in an intent (see http://android.amberfog.com/?p=98 for details) or just show a msg to the user that it's safe to delete the data app.
HTH,
llappall
by dropping a specially formatted file into a specific directory
You can do that on external storage. Create a directory, and check it when your app starts up for new files. Tell the user they have to stick the magic files in the magic directory for it to work.