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. Voice conferencing in Android2.1


I am trying to develop an audio conferencing application in Android
2.1. Have just started in Android. If any body could tell me about an
audio conferencing api(if already there, if not then please give me a
hint how to merge the voice) it will be a great help.



2. getElementsByTagName or loop

I want to retrieve data from an xml file.

Currently I am using dom.
Should I use getElementsByTagName() many times or use a loop and parse
the dom tree manually?

getElementsByTagName() is easy to use, but I was wondering it would be
more efficient for the android to use a loop?



3. decorat 2010


5. Audio Flickering - my code, my computer or android emulator?

6. "android update sdk" on headless linux

7. How to build ?