Android Open Source - Android-Advanced-ImageView Data Clean Manager






From Project

Back to project page Android-Advanced-ImageView.

License

The source code is released under:

GNU General Public License

If you think the Android project Android-Advanced-ImageView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.appsdk.advancedimageview.util;
/*  w w w  .  j av  a2 s .  c o  m*/
import java.io.File;
import android.content.Context;
import android.os.Environment;

/**
 * ??????????????
 */
public class DataCleanManager {
  /**
   * ?????????(/data/data/com.xxx.xxx/cache)
   * 
   * @param context
   */
  public static void cleanInternalCache(Context context) {
    deleteFilesByDirectory(context.getCacheDir());
  }

  /**
   * ????????????(/data/data/com.xxx.xxx/databases)
   * 
   * @param context
   */
  public static void cleanDatabases(Context context) {
    deleteFilesByDirectory(new File(context.getFilesDir().getPath() + "/data/" + context.getPackageName() + "/databases"));
  }

  /**
   * ?????SharedPreference(/data/data/com.xxx.xxx/shared_prefs)
   * 
   * @param context
   */
  public static void cleanSharedPreference(Context context) {
    deleteFilesByDirectory(new File(context.getFilesDir().getPath() + "/data/" + context.getPackageName() + "/shared_prefs"));
  }

  /**
   * ???????????????
   * 
   * @param context
   * @param dbName
   */
  public static void cleanDatabaseByName(Context context, String dbName) {
    context.deleteDatabase(dbName);
  }

  /**
   * ??/data/data/com.xxx.xxx/files????
   * 
   * @param context
   */
  public static void cleanFiles(Context context) {
    deleteFilesByDirectory(context.getFilesDir());
  }

  /**
   * ????cache????(/mnt/sdcard/android/data/com.xxx.xxx/cache)
   * 
   * @param context
   */
  public static void cleanExternalCache(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
      deleteFilesByDirectory(context.getExternalCacheDir());
    }
  }

  /**
   * ???????????????????????????????????????????
   * 
   * @param filePath
   */
  public static void cleanCustomCache(String filePath) {
    deleteFilesByDirectory(new File(filePath));
  }

  /**
   * ????????????
   * 
   * @param context
   * @param filepath
   */
  public static void cleanApplicationData(Context context, String... filepath) {
    cleanInternalCache(context);
    cleanExternalCache(context);
    cleanDatabases(context);
    cleanSharedPreference(context);
    cleanFiles(context);
    for (String filePath : filepath) {
      cleanCustomCache(filePath);
    }
  }

  /**
   * ???? ????????????????????????directory???????????????
   * 
   * @param directory
   */
  private static void deleteFilesByDirectory(File directory) {
    if (directory != null && directory.exists() && directory.isDirectory()) {
      for (File item : directory.listFiles()) {
        item.delete();
      }
    }
  }
}




Java Source Code List

com.appsdk.advancedimageview.AdvancedImageCarouselViewGroup.java
com.appsdk.advancedimageview.AdvancedImageCarousel.java
com.appsdk.advancedimageview.AdvancedImageView.java
com.appsdk.advancedimageview.listener.AdvancedImageCarouselClickListener.java
com.appsdk.advancedimageview.listener.AdvancedImageCarouselSwitchListener.java
com.appsdk.advancedimageview.listener.AdvancedImageViewLoadListener.java
com.appsdk.advancedimageview.util.AssetsManager.java
com.appsdk.advancedimageview.util.AsyncLocalImageLoader.java
com.appsdk.advancedimageview.util.AsyncNetImageLoader.java
com.appsdk.advancedimageview.util.BitmapCache.java
com.appsdk.advancedimageview.util.DataCleanManager.java
com.appsdk.advancedimageview.util.MD5.java
com.appsdk.advancedimageview.util.MessageDigest.java
com.appsdk.advancedimageview.util.MyLruCache.java
com.appsdk.advancedimageview.util.mConfig.java