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

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

Related

How to retrieve the names of the music files i upload in firebase storage manually?

I have uploaded some music files in firebase storage bucket manually, not programmatically.
Is there any way to get the names, the links from which I can stream it in my android application written using java.
I got similar questions and answers in Stack Overflow but in all cases the uploads are done programatically and not manually like in my case.
I tried searching everywhere but what i always get is an upload that is done programmaticatlly which makes it simpler to get the download url.
You will need to store the list of files somewhere that is known by your app. Perhaps it could be in another file in Cloud Storage, or a database.

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.

where to persist multiple image files on android

I'm writing an android app that makes use of many images(dozens). These images, like most of the other data in the app, are updated from a remote database. For the data I am going to have a local database and sync it with the remote database every time the remote db is updated.
The remote database will store the images as URLs, and my app will download the images from these urls to display them in the app. So I could just have my local database sync with the remote one and I'll have the URL of all the image files I'm using and I can re download them from the remote server every time the app is run, but this is obviously slow and wastes a lot of data.
What I want to do is, everytime the database is updated and needs to be synced, the app will sync its local db and download the new images from their URLs as usual, but then it will save the image files somewhere on the device, so next time the app is run it can just grab the images from the device.
I can't seem to find an effective way of doing this, perhaps it's because it's a bad idea to do it this way in the first place? Sharepreferences probably won't have enough room, external storage isn't available all the time, and I hear it's a bad idea to just store a big chunk of binary data(such as an image) in the local database.
What are my options here?
Start with Android Storage Options.
Further:
external storage isn't available all the time
That's true in theory, but in practice, you'll have external storage 99% of the time, especially if you're developing for newer devices. Note that "external storage" and SD Card aren't the same thing -- the terminology here is confusing. For this, use getExternalFilesDir().
Regardless, if your image storage is a reasonable amount (<100MB is reasonable IMHO), then you can just use internal storage. As of Android 3.x, this won't cause a device to run out of space like early devices did. In practice, you'll be fine 99% of the time. Here you might want to use the cache dir, returned by getCacheDir().
In one of my apps I have a large number of files that are synced with a CDN. I use the sync process and database to retrieve download URLs and MD5 hashes of the files. If the MD5 hash has changed, then I download the file again in the background. I simply store the file using the hash as the file-name, so I can easily resolve duplicate files. Periodically, I also walk the cacheDir to see whether there are any files that are no longer referenced in the database.

Downloading (paid-for) content into an Android application

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

Application that use a lot of MP3 files?

I have a general doubt about how to design Android apps that use a lot of MP3 (or other audio) files. My problem is that I do not know what is the best way/location to store such files.
I know that these options are available:
Store them on a remote server and fetch via gprs/wifi on demand (like, on a button click)
Store them locally inside the app (taking care they do not exceed the max size)
Store them locally on the sdcard (a user could delete them)
Store them both remote and locally
Could you tell me what is the best way to do? Also, if you store these files locally, do you download them after a user installs an app or you use some other method?
For example, my last app had approx 400MB of MP3 files and I was in a deep doubt where to store them. I chose remote web server, but I am not sure that was the right choice.
Thanks in advance
I'm interested in how you convince people to download 400MB of Music-files. You should compress them.
I would store them on the SDcard. If the user deletes them -> His problem (you could give him a message). But streaming them is a bad idea because if the user has no connection, he can't hear anything.
Downloading the files after the user installed the App (like the "Need for Speed Shift"-App) would be an option, too. In this case, you would save them on the SDcard, too.

Categories

Resources