Downloading (paid-for) content into an Android application - android

I have a simple application that should handle (display, play...) data downloaded by users. I.e. when the user downloads the application (for free), it is empty, or filled just with some sample data, but then the user can download the actual content of their preference (and potentially pay for it via Android billing system). Each item is a folder with an xml file plus several sub-folders (such as audio and images). In the development phase the data are stored in the assets directory.
The payment itself is not a subject of the question at this point. I am actually interested in the following:
where can I store the downloaded data in the phone so that it would be accessible for the application but so it could not be copied manually by the user (for example to another phone). It would be ideal if I could store the downloaded data in the assets directory but I'm afraid once the apk file is generated, assets are "locked" and cannot be easily extended (or can they?) If I store them on the phone's card (or in the built-in memory), they will be accessible by other applications such as media player or galleries, too, won't they?
it would be great if I could download the package as a single single file - is it possible to upack it by an built-in method and store it as a folder with upacked (and thus readable) sub-folders and files?
when the application is downloaded, it is an apk file. Therefore it should be possible to have the sample data (i.e. downloaded with the application) at the same location as the data that will be downloaded later. How can I ensure this.
the data can be pretty large and therefore it is not an option to have all of them included in the assets folder immediate after the download and unlock it on basis of the user's actions
once the data are downloaded, they must work off-line (i.e. the user must be able to display them without internet access; thus it is not possible to check identity of the user on the server - they can simply display anything they have previously downloaded)
Example (for clarification purposes): have an application able to display recipes. It does not contain any or just a few after installation. You should be able to download recipes (one by one) from a server (each having a certain file structure stored in a seperate directory). Once they are downloaded, they become an integral part of the application and always accessible for the user even if the use the airplane mode of their phone.
Hope it makes at least some sense (I can clarify the question further if it doesn't). I've found several tutorials on how to work with data stored in assets and on how to handle data on an sd card but none concerning this particular topic.

you may store your date in your application data folder, basically it's available to your application only. if you want to prevent your data to be copied to another phone, generate a random UUID on the first run, and then use it to encrypt your data stored in the data folder. another phone will have different UUID and different encryption key, making it pointless trying to copy encrypted data. you may even use non-symmetrical encryption and send your generated (public) key to the server and have the server to encode your data and send it back in encrypted form, thus preventing your data to be exposed at all.
the assets/ folder is generally read-only, you may put your data there only during the build step.
make your file a .zip file -- these are compact and you may easily read files and folders and whatever you need using java.util.zip.ZipFile
sample data goes into assets folder, you may copy it out to the data folder on the first run.
once you download the data and save it to the device, i don't see any reason why your application won't work offline

Related

Android: Add audio and image files downloaded from server to app data

I am creating an app where the user will find a topic of interest, and download audio and images related to this topic stored using NoSQL database. I don't want the user to have direct access to the file after downloading, since the content should belong to the creator. The data should be downloaded, not streaming, as in some cases the user may not have internet access.
I wasn't sure how to go about this. I thought the files could be downloaded to the resources folder for each instance of the app. First, I could not find how to do this, and I also wasn't sure if I would reach a maximum memory limit.
An alternative I thought of was to encrypt the files then decrypt them within the app.
Thanks!
Alex

how can i keep a folder in my mobile storage and a folder in my dropbox space in Sync?

i have developed a android app for farmers. it is a informative app for indian farmer.The users will be sending me the images and video files to me through my app. here i used (integrated) dropbox to receive those files directly to my dropbox space. whatever the image or video taken by the user, it will be stored on a folder in my mobile storage. Here what i want is, i want the folder in my mobile storage to be in sync with the folder in my dropbox.
How can i do this?
there is a app in market called Foldersync which exactly fulfil my requirement. how they are doing it? How can i keep a folder in my mobile storage and a folder in my dropbox to be in Sync?
Note :
i have gone through drop-box api and created a simple app to send files directly to my dropbox space and i know how to download a entire folder from dropbox.
But here my question is unique from that... pls don't answer the above points which i already know..
Please help!
Thank You
You can use the Dropbox API to keep a local client in sync with Dropbox. There are two main pieces to this:
1) Metadata:
Assuming you're using the Core API, the best way to get information about all of the file and folders in an account (or optionally under a specific path) is to use /delta:
https://www.dropbox.com/developers/core/docs#delta
With this, you can get information about everything your app can see, and then easily stay up to date with changes. There are some useful blog posts on using /delta here:
https://blogs.dropbox.com/developers/2013/12/efficiently-enumerating-dropbox-with-delta/
https://blogs.dropbox.com/developers/2013/12/filtering-dropbox-delta-results-by-path/
2) File content:
Using the metadata retrieved from #1, you can download any files you need access to locally using /files (GET):
https://www.dropbox.com/developers/core/docs#files-GET
You can upload locally changed files using /files_put:
https://www.dropbox.com/developers/core/docs#files_put
Or, for larger files, use chunked uploading:
https://www.dropbox.com/developers/core/docs#chunked-upload
https://www.dropbox.com/developers/core/docs#commit-chunked-upload
The main work here will involve programming the logic in your app to correctly receive changes from the server as well as upload local changes, in order to keep everything in sync.
Also, be aware that on mobile devices, bandwidth can be limited and/or expensive, so be careful to not accidentally automatically download a lot of data the user doesn't want or need.

deploy extra data files to deployed android app

Consider an app with a set of data files (could be music or pictures or locations or indeed anything at all) embedded in the apk.
I now want to provide to the user additional data files , either to replace or add to the original data files - the user should be able to select which files to download and not have to reinstall the whole app.
So the question is it possible to do this non-programmatically - like by providing extra apk files for the app but which only contain single data files?
This is a good use case. A simple idea could be, ask the user to check for updates, you download a XML file which defines your updates. Parse this XML file and show what the user needs to download. Then you download and save it to desired locations. Always version the XML file so that you know if updates are avialble or not!

Start Android app with files on sdcard or somewhere in the filesystem

I making an application with phonegap/cordova where I need to keep a lot of files up to date. Some files (mainly images) will need to be erased in time, and some new ones will get downloaded. The thing is, in Android, to manipulate those files, it seems I need to have them on the sdcard; so I copy the files the app starts with from my assets folder to the sdcard. It just seems like a waste of memory space.
Do you know if is there anyway I can start with the app having those files the app starts with already inside the sdcard? or at least somewhere I can delete them later?
Thank you.
Files that are delivered to the device as part of your APK will be stored in a form that cannot be modified by your application (other than by updating to a new version of the apk).
If you copy the files out of the APK into the private internal storage area or the external storage area, those copies can be modified, but the originals inside the apk will remain.
The most efficient solution may be to not put these files in your apk, but have your app instead download them separately on the first run, using whatever mechanism you wanted to use to change them in the future.
(Some people object to this feeling that such files are less secure against unauthorized use, but as the contents of an .apk are trivial to extract this is not a strong argument. Needing to maintain a server to download from is a slightly more substantial objection.)
You do not need to store the files on the SD Card. Each app has its own internal storage that is not accessible by any other apps. For more information see the official docs: http://developer.android.com/guide/topics/data/data-storage.html

Distribution a file with my android project that will be updated in the future

I'm creating a simple Android App, it will be a map with a number of points marked on it. These points will sometimes change, based on an XML file hosted on the internet.
To reduce the initial load time my intention is to distribute a serialized List of these points with the application that can be updated in the future.
At first my intention was to distribute this serialized file as an 'asset'. This way I could just generate the file and drop it in to 'assets'. However, this does not work because (from what I can see) it is not possible for me to overwrite these assets.
The second option was to use the internal storage, however (from what I can see) I can't distribute this file as 'internal storage'.
Is my only option to distribute my serialized List as an asset and then on the initial load copy it to the internal storage? The files only going to be around 50kb but it seems unnecessary to have 2 copies of the same file (1 of which will eventually become outdated) as part of the same application.
How about always first checking the internal storage and if your data does not exist there read the 'asset' version.
Then you will have a syncronization job that will download the updated file (when available/updated) and put it in internal storage. But yes I guess you will be stuck with always having the original file there.

Categories

Resources