I have a lrucache that could contain static data, so that even if my app is closed when user returns he can find data faster.
However this takes about 10-15 MB of memory and so I’d like to make an if branch like this
if(deviceOverallRAM > treshold)
preserve static memory on app exit
else
clear static memory on app exit
So, can I get device’s ram, maybe through some hidden api? And what would be a good value for the treshold?
To do this pre-API 16 you have to read the proc/meminfo file of the android kernel:
Source: this question
However, in API 16 and onward, you can use the following code to retrieve the total memory: