I have an android app which I want to keep light so I thought I'd store its many mp3 audio clips in Firebase Storage, and about a dozen of these (total size around 200kb) are downloaded the first time a user opens any new recyclerview list before they are playable. It works as intended, problem is the download is incredibly slow and the user waits 20-30s before they can play the files - not acceptable. I've seen other posts complaining of this download speed issue with FB Storage, and one of the few suggestions was to use FB Hosting instead as this is apparently faster. As a newbie I'm struggling with the documentation for this but it seems to be designed to use with web apps, and mine is a mobile app. The other suggestion I saw was to make the files publicly available in FB Storage. I don't particularly want to do this, but would consider it if was my best solution. Is it?
Can FB Hosting be used to store media files for mobile apps? Or should I use another cloud storage service such as Dropbox, whose free 1GB storage would be plenty for me? Could it handle heavy traffic / simultaneous downloads the way I guess FB is designed to? Or should I use a CDN? The app will, hopefully, have users spread globally. I want to use FB anyway for the other tools it provides, but where / how should I store my audio files so they will download quickly? Thanks for advice.
I had the same issue around 2 years ago, I've moved to Amazon Storage S3, which was much faster than Firebase Storage.
I made the files publicly available in FB Storage and now I have very fast downloads, so this seems to be the solution. Instructions are here making data public
Related
Is there a place where I can store and manage my own images outside of internal storage? I don't want other apps to be able to see or access these images. Should I use external storage? Does such a place exist in the new MediaStore? It's fine if they're deleted when the app is deleted.
This solution needs to support API 21 or higher.
I know there are a lot of questions like this, but they're 10+ years old and a lot has changed since then.
Use case / background
I have an app where all data is stored locally on the device (no external servers).
Users can choose custom background images for journal entries. A user could choose to use a different image for each journal entry they create. They can create as many journal entries as they want. They may revisit those journal entries. So, I need to store an unknown amount of images for the lifetime of the app. I've been saving a copy of the images the user picks from the gallery in my local app storage via context.filesDir.
I noticed a crash Fatal Exception: android.database.sqlite.SQLiteDiskIOException disk I/O error (code 4874 SQLITE_IOERR_SHMSIZE) and after googling, I found This error may indicate that the underlying filesystem volume is out of space.
My concern is that my app is running out of internal storage space because of the user images I'm storing.
Where should I be storing these images? I originally chose internal storage because I wanted my users' images to be reasonably private (since I don't know if they're storing sensitive images or not). I also wanted to make sure the images would always be available even if the source image (chosen from user's media) is deleted. However, I hadn't considered the limits imposed on internal storage. Silly me!
Darshil's answer is correct. Using the recommended Storage Access Framework for your use case, you should use getFilesDir() which will return your app's internal storage, which is private to your app.
Where should I be storing these images?
problem is due to limit of resource which is out of our control. However if you really want to store all the images, you can take some approaches:
1. Online: Use some cloud servers for storing user data. This might cost you a lot.
2. Offline: Tell user that you have only the limited amount of storage and storing more images will require to delete some older ones.
3. Both: Store in device. When internal storage is running low, tell user to buy some type of premium subscription to store unlimited cloud photos.
Android does not provide a place for you to store private photos (can't be accessed by user or other apps) outside of app's internal storage. I know you can contradict me by saying that one can store them in external storage by using getExternalStoragePublicDirectory() but the problem is that it is a shared directory accessible to users and other apps and remains when the app is deleted.
So I suggest you to use getFilesDir() as the directory returned by it is hidden from users and is deleted when the app is deleted. And also implement a image compressing tool in your app which automatically compresses images when uploaded by the user and then save it to internal storage. This won't solve the problem completely but I guess it's a start.
I would recommend checking out AWS Amplify which allows you to integrate your application with AWS services. For what you have described, you could use amplify to give your app the ability to authenticate users and set up cloud storage on AWS S3 which you can configure to only allow users to access and edit files that they have uploaded. One nice thing about AWS Amplify and AWS S3 cloud storage is that there is a free tier which allows you to develop your application for little to no cost. Depending on the amount of data that you will be uploading, it may be quite a while before you surpass the free tier limits.
A guide like this one may help you learn more.
I am not sure if I fully understand your question, but writing a quick tip.
try cloud services to store your images like AWS s3, cloudinary. Cloudinary is much cheaper if you want to try like 25gb/month free.
With limited storage space appearing to be the root cause, I recommend intentionally using the UI to encourage users to use existing images over new images. (This can work in addition to the technical options provided in other answers)
For example, present the user with a list of available background images and a link to add a new image. In this case, using an existing image is 1 click with a preview, where getting a new image requires opening a new view and searching for the new image.
Using the UI in this way doesn't directly get you more space, but it can help you to more efficiently use the space you have by guiding users to use existing images. It also gives you a place to warn about (or limit) adding more images when there is not more space available.
*If you still must have more storage on the device outside of the app, you could try using the public space with encryption for "privacy".
I have the next problem:
To my graduation work my teacher told me to implement a system that allows me to transfer any type of file from a phone (Android, IOS...) to another phone (Android, IOS...) using a server that keeps the files until the target phone downloads it.
Could anyone give me some advice about the best way to do it?
Thanks in advance.
You can use Firebase Storage, it has a free plan (so it's nice), and it gives you a nice API in Android and IOS, it allows you to upload and download files easily.
read more here: https://firebase.google.com/docs/storage/
I'm developing an app that would have an In-app purchase and download Videos from my server and store them on the device.
The problem is, the Videos are paid videos and are to be maintained in a highly secure place inside the app itself.
What are the possibilities of doing it? I had a look at setting android:exported="false", but it just restricts other apps to access my app's data. But how do I store the videos in a place which are restricted to be viewed by default even when connecting the device to a PC?
Are the apps allowed to store data in the device's \data folder? If so, please tell me how!
You can store files in your app's data folder, and as long as the phone isn't rooted, only your app should be able to access them.
However. The local storage on phones is generally limited, so storing videos there is a bad idea. Also, unless you're integrating your own video player, you might have issues trying to get the phone to play videos in your private folder.
To speak to the security issue, I'd suggest trying to keep them on the sd card, and experiment with either encrypting them, so they can't be read raw from disk, or (possibly) experimenting with file permissions, although I doubt the latter would work.
To do the encryption, I'd download the video, encrypt it and save it to the sd card. When you want to watch, decrypt and temporarily save to local storage for viewing. Not sure what kind of performance that will get, though. Plus, if you're relying on the OS to play your videos, you could have the same permission issues mentioned above. Depending on how critical this all is, you could explore something where the file/folder structure is obscured, so getting at them manually is more complex. Won't prevent all grab attempts, but will deter casual users.
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.
My app has several image and media files, which are around 1MB each or so. So if i follow the normal way, the app size is crossing over 40MB, which is huge. Is there anyway to avoid this?
I have heard of external storage, but i really don't get any clue of how to work on them!
Do i need to ask all those who instal this to save the images and media files in the external disk and then the app uses those? This makes my files public..isn't it?
I actually don't own a android device. So is it like, whenever people install an app from the market, does it ask if it has to install in the phone memory or the external memory?
I really need your help.
If there is a way, i'd be thankful if you can provide me the step by step details of how this can be done!
Thanks a lot..
Regards
Nithin
There is, from the little I know of this, a slight security risk from putting files onto the SD card. I don't think I personally would worry too much about that since most people that would want access to the files in your apk (Which does not include your source code) could get it regardless without too much trouble.
As of Android 2.2 the user has the option to move an app to their SD card, but only if the developer explicitly tells the app to allow it. I'm fairly sure this only applies to 2.2+ devices though, so being that you are likely going for a larger audience than that it isn't an end-all solution. I am only really pointing this out in case you do end up putting one large file on the market. If so, be sure to allow the transfer to SD card, your app will stay on devices much longer.
Downloading the files online from within the app and saving them out to the SD card would be a good solution, though I am not sure how end users feel about downloading a small app then having to download a very large package before using it. In the end they will have to download it either way, so it is up to you whether you want to ask them to do it up front in the market or afterwards via the app. If you do want to try to download all the content then maybe the code example in this link will help you figure it out :
http://androidsnips.blogspot.com/2010/08/download-from-internet-and-save-to-sd.html
You might consider streaming the files or downloading them inside the application to the sdcard. Speaking from experience my users have had problems downloading apps as big as 30MB. Some phones also have a severely limited internal memory, which is where the applications are downloaded to.