getCacheDir() not working

by DanaH » Mon, 07 Dec 2009 13:54:52 GMT

Sponsored Links
 I am attempting to follow a code snipet for saving a file to a cache
directory without success.

    File pathCacheDir = getCacheDir();
    System.out.println("Got the Cache directory");
    File newCacheFile = new File(pathCacheDir, cacheFileName);
    FileOutputStream stream = new FileOutputStream
    tileImage.getBitmap().compress(CompressFormat.PNG, 100, stream);
}catch(Exception e) {
    Log.v(TAG, "Not able to save tile to Cache...");

The first debug statement that prints out is in the caught exception,
which tells me that the getCacheDir() call is where the failure
occured. Upon doing further investigation, I found that the /data/data/
<package name>/cache/ file does not exist by examining the file
structure in the DDMS.
Should the cache dir be a pre-existing directory? In any case, I have
since been able to created it explicitly. However, the program is
still failing at the same getCacheDir() call.
Is this likely a bug in the SDK, or am I missing some key information?


Other Threads

1. Highlighting Text Color using Html.fromHtml()?


I am developing an application in which there will be a search screen
where user can search for specific keywords and that keyword should be
highlighted. I have found Html.fromHtml method.

But I will like to know whether its the proper way of doing it or

Please let me know your views on this.



2. How to fill remained available space if i want to put a button to bottom?

Use the "weight" or "layoutWeight" property on the ScrollView (can't
remember which it is, look it up).

TreKing - Chicago transit tracking app for Android-powered devices


3. Cannot Play Audio Files In The RAW Folder

4. How to unregister listener after application get closed

5. Spinner-SimpleCursorAdapter

6. Send SQLite db to web server

7. How to get Gmail address registered on the phone ?