O'Reilly logo

Android Application Security Essentials by Pragati Ogal Rai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cache

If an application needs to cache data, it is prudent to use a cache storage mechanism provided by the Android stack. Android stores cache files in the filesystem along with the application so that they are sandboxed with the application that created it. All cache files are created in the /data/data/<application-path>/cache/ directory. In case the system is running low on memory, these cache files are deleted first. Regular pruning of these files is necessary as they may grow big and eat up disk space.

The following code snippet first writes a string to the cache file and then reads the same string from the cache file. As you will notice, reading and writing is the same as any file input/output, only the location of the file is obtained using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required