public FileCache(Context context, Util util) { // Find the dir to save cached images if (android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED)) cacheDir = new File(android.os.Environment.getExternalStorageDirectory(), "Obliquity"); else cacheDir = context.getCacheDir(); if (!cacheDir.exists()) cacheDir.mkdirs(); mUtil = util; running = false; tempDirSize = 0; mContext = context; if ((mDirSize = mUtil.getLong(KEY, -99)) == -99) initDirSize(); // If Util has no dirSize calculated if (DEBUG) Log.d(TAG, "MAX CACHE SIZE : " + maxDirectorySize + " MB"); setupDirectoryOverflow(); if (DEBUG) Log.d(TAG, "FileCache mDirSize : " + mDirSize / 1024. / 1024. + "MB"); }
// Commits current mDirSize to file preferences public void commmitDirSize() { if (DEBUG) Log.v(TAG, "CommitDirSize : " + mDirSize / 1024. / 1024. + "MB"); mUtil.addLong(KEY, mDirSize); }