Reduce Android App Storage Size built through MAUI - android

I built a basic android app that takes some inputs from the user, does some calculations and displays the output.
But the final size of the application is turning out to be 114MB, which is huge. :(
I tried deleting the user data by clicking on Clear Storage, but then I am unable to start the app itself.
Can someone help me with a way to reduce the app storage size?

I am unable to start the app itself
This must be some crash, read the log and solve it.
As for reduce app storage size, you can find all the directories you used, and make a clean cache entrance for user to clean the cache by themselves.

Related

Best suited methods to include large number of images,videos,pdf in an offline application

I need to develop an offline application in which it has got around 700 images, around 100 videos, 100 pdf's need to be included along with apk.Currently i have put images in drawable folder,videos in raw folder, and pdf in asset folder.When i build the application including all this apk size goes upto 1.5gb.My question is
1.Is it appropriate to include images and video in res folder?Is there any other method to handle this situation
3.One peculiar error will get generated when you build the app that is "package r does not exist android studio".Even though apk gets generated,studio shows this error
It's best to make use of Google Play APK Expansion Library for handling large application data. Imagine having the user download/install a single 1.5GB APK file.
Possible reason: R is re-generated by your environment everytime you add a new resource, as you are using a lot of files this may take time and during the process you will get the error R doesn't exist
Best way would be if you keep the app light without images and videos, only download the files from the server after the user installs the app, on a per need basis. You can save these in the SD card and save users on phone storage space as well.
First of all, if there's gonna be so much data then it should not be in stored in the App (APK). Also google doesn't allow this big APK to be uploaded at once, the big apps are divided into parts. You must have seen for the big games it first downloads a game, it starts and then downloads big amount of data later. But in your case I think the standard way to handle this situation would be to keep all this data on the server and whenever you need it just request it from there.
The best suited for this is to use "facebook conceal"

Caching an Android application data, is it safe to always use getFilesDir()?

Is it safe to always use "getFilesDir()" as the only destination to cache your app's data?
Will that directory always be available?
What happens when the destination has no free space? does Android handle that?
Will that directory always be available?
Yes.
What happens when the destination has no free space? does Android handle that?
Android has no ability to magically cause a device's on-board storage to increase in size. Android takes various steps to try to help the user clean up used storage space. However, eventually the user can still run out of space. Depending on how you are working with internal storage, you may get an IOException, or you may get a silent failure (e.g., write a zero-byte file).

Save Object to Internal Storage at Application Install

I would like to know if its possible to save an object at the moment the user is installing the app on mobile.
Why I want this?
My app uses some default objects to his normal behaviour, whenever the user starts the App I want that the objests are there to be used. I could certainly just create them each time the user opens the app..
But that might consume a bit of unnecessary time and performance and battery.. If its default, I want to create only once, and then its always there.
I will also use Internal Storage to create new objects of this type, there will be the default ones, that I described above, and there will be also the option to create new ones and save them to use later, on another time that app is launched, but that its fine, I already read something about how to serialize the object and use internal storage to keep them :)
I am just here asking about the first question, create the item only once at the beginning, maybe on the install moment of the app? I was assuming.. but dont know if its possible.
It has been very helpful to have this space for over an year, I have already learned a lot here from you thank you ;)
Android provides following intent to detect app installation
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
If you use these with conjunction with broadcast receiver you will be notified when user install a new app. Problem with this solution is, it will not help you as you are trying to detect your own app installation.
What you could do is every time user launch your app
check if object exist
if not create one and write it to internal storage.
in this way it will created once. Depend on type of object you are trying to save you might consider using SharedPreferences or SqlLite or simply a file IO. If you are writing Java Object yes serialization is the way to go.
Update
If you are planning to get data from network for the first time, depend on the size you can decide,
Small File: Put it inside Asset folder and ship it with apk.
large file: if the file size is huge you might consider to ship portion with apk and sync and update rest on a background process or download everything from network
I'm not sure what you mean. A Java object exists in memory, so "saving" it when the user installs the app makes little sense. It can't remain in memory unless some process is holding onto it.
If you mean something like a JPEG photo or other data, you can put the data in the directories of your project and then access it as a resource once your app is installed. See the
Providing Resources API guide.

Android & Admob unexpected data storage and cache values

after adding adMob ads to my application, I have noticed some strange memory behaviour. On my android phone, If I go Settings>Applications>Manage applications>myApp
I obtain the storage information for my app.
What concerned me was that the Data storage was around 600kb, and the Cache was over 2.5MB (as opposed to 28kb and 0kb maximum without admob).
After some trial and error, I discovered that the Data storage value seems to increase with the cache. If I clear the cache and restart my app, the data value drops significantly, back to what I would expect for my program.
I have no idea what this cache is doing, but it is related to adMob. I have not integrated any specific cache management in my program. I worry that if this cache content grows as it has been, then the users of my app will not be impressed if my App starts taking up 10+MB of space. Should I be worried? Could it be that because I did nothing than run my app repeatedly for a day that no other app or program will have outed my data from the cache? Should I manually clear the cache? what is it's purpose with regards to Admob?
Admob is just caching its ads so they load quicker. The Android OS will clear the /cache directory if the filesystem gets too full, and Admob should be managing its own cache size. You shouldn't have to worry about it
when use the admob,it save some file(cookies,index etc) under Android/yourfile/app_webview. if you dont want increase your data usage, you can delete the file before exit your app.

android loading and saving images on the device

I am building the application that will load list of news from the website. Each news/headline has an image. I want to save/cash the images so user does not has to download them again.
Q: In your opinion, what would be a better/more sufficient way: Loading images and saving them on the device or use the CacheManager? At the moment I am using the first solution and everything works fine. However, the website has many categories and even more news per category therefore there are lot of images saved on the device. Is it normal in this type of applications to save the images on the device?
Thanks for your help,
marqs
I don't think you should save the images on the device, because of many reasons:
Why wasting the device space on news images? All the user wants is to read the news and thats it. (In your case maybe open it later, but still - not forever)
You can save it on the device and make the app. delete those files after lets say 24 hours..
The main issue is the privacy issue, when the user is deleting the cache files he thinks all the webs he visited has wiped from the device, but in this case they aren't..
Maybe you can just add a "Clean Cache" button in the app. but after all I wrote I think using the Cache-manager is the best way - just because it was meant for those things exactly..
:)
Rotem
I didn't find a reason to use CacheManager. I used getCacheDir and stored everything on file. I have two levels of cache. First when I fetch it, I store in memory and disk. When in memory gets bigger than 30 objects, I started clearing the memory to make some room for the new images coming. However, I still keep the images around on disk and bring in to memory as needed. I found this to give me the smoothest scrolling. After about an hour, I start expiring the image on disk too.

Categories

Resources