How can I get informations within code about the cache of my app?

user3890967

I want to check where my apps cache is raising all the time. So I need a method to access informations about the current cache at any time. I think there must be such a method, because I could see the size of the cache in the App-Info of my android-smartphone. The app is running in the background and I want to log when the size of the cache is raising.

Android Team

Use below code snippets for your solution.

public static byte[] retrieveData(Context context, String name) throws IOException {

        File cacheDir = context.getCacheDir();
        File file = new File(cacheDir, name);

        if (!file.exists()) {
            // Data doesn't exist
            return null;
        }

        byte[] data = new byte[(int) file.length()];
        FileInputStream is = new FileInputStream(file);
        try {
            is.read(data);
        }
        finally {
            is.close();
        }

        return data;
    }

Here is complete CacheManager class.

When to clear the cache dir in Android?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error within my code how can I centre responsive image?

From Dev

How can I get GPG Agent to cache my password?

From Dev

How can I get GPG Agent to cache my password?

From Dev

How can I see if my password variable is within a line so that my code can proceed?

From Dev

Can I use WebAssembly to safely execute untrusted user code within my web app?

From Dev

Can I tell within application code, on what outermost port of my server the app is accessed?

From Dev

How do I get the local Currency Code for my android app?

From Dev

Android, How can I get my app is going to uninstall

From Dev

How can I get rid of the animation when resetting my app?

From Dev

How can I get the font names bundled in my iOS app?

From Java

How can I get my code to return the correct variable?

From Dev

How can I get my code to stop in Visual Basic?

From Dev

How can i get my php source code length?

From Dev

How can I catch the Console log output within my own app in Xamarin.iOS?

From Dev

How can I have a server side faye client running within my rails app?

From Dev

How can I filter by domain name within my Rails app in Heroku?

From Dev

Android headache with Strings: How can I centralize all strings within my app?

From Dev

How do I get a QR code to from my telerik app-builder project so that I can scan it and preview the application from my device?

From Dev

How can I integrate some code that is being rendered on html tag within my custom module in magento

From Dev

Can I disable systemui From within my android app?

From Dev

Can I Build my app within a week with Supersonic UI ( AppGyver )

From Dev

how to get informations about relationship of tables in oracle?

From Dev

How to get more informations about this device?

From Dev

How can I get my array to only be manipulated locally (within a function) in Ruby?

From Dev

How can I get my Chart.JS to center within a div?

From Dev

how can i condense my XML and Java code to make my app run smoother

From Dev

how can i condense my XML and Java code to make my app run smoother

From Dev

How can I get a transparent background in my iOS app so I can see the Home Screen wallpaper?

From Dev

How can I share my hosted app's code in Google App Engine

Related Related

  1. 1

    Error within my code how can I centre responsive image?

  2. 2

    How can I get GPG Agent to cache my password?

  3. 3

    How can I get GPG Agent to cache my password?

  4. 4

    How can I see if my password variable is within a line so that my code can proceed?

  5. 5

    Can I use WebAssembly to safely execute untrusted user code within my web app?

  6. 6

    Can I tell within application code, on what outermost port of my server the app is accessed?

  7. 7

    How do I get the local Currency Code for my android app?

  8. 8

    Android, How can I get my app is going to uninstall

  9. 9

    How can I get rid of the animation when resetting my app?

  10. 10

    How can I get the font names bundled in my iOS app?

  11. 11

    How can I get my code to return the correct variable?

  12. 12

    How can I get my code to stop in Visual Basic?

  13. 13

    How can i get my php source code length?

  14. 14

    How can I catch the Console log output within my own app in Xamarin.iOS?

  15. 15

    How can I have a server side faye client running within my rails app?

  16. 16

    How can I filter by domain name within my Rails app in Heroku?

  17. 17

    Android headache with Strings: How can I centralize all strings within my app?

  18. 18

    How do I get a QR code to from my telerik app-builder project so that I can scan it and preview the application from my device?

  19. 19

    How can I integrate some code that is being rendered on html tag within my custom module in magento

  20. 20

    Can I disable systemui From within my android app?

  21. 21

    Can I Build my app within a week with Supersonic UI ( AppGyver )

  22. 22

    how to get informations about relationship of tables in oracle?

  23. 23

    How to get more informations about this device?

  24. 24

    How can I get my array to only be manipulated locally (within a function) in Ruby?

  25. 25

    How can I get my Chart.JS to center within a div?

  26. 26

    how can i condense my XML and Java code to make my app run smoother

  27. 27

    how can i condense my XML and Java code to make my app run smoother

  28. 28

    How can I get a transparent background in my iOS app so I can see the Home Screen wallpaper?

  29. 29

    How can I share my hosted app's code in Google App Engine

HotTag

Archive