content: package com.liyi.sutils.utils;
  
  import android.os.Environment;
  
  import com.liyi.sutils.utils.io.FileUtil;
  
  import java.io.File;
  
  /**
   * 清除相关工具类
   */
  public final class CleanUtil {
  
      private CleanUtil() {
          throw new UnsupportedOperationException("cannot be instantiated");
      }
  
      /**
       * 清除内部缓存
       * <p>/data/data/com.xxx.xxx/cache</p>
       *
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanInternalCache() {
          return FileUtil.getInstance().delete(SUtils.getApp().getCacheDir());
      }
  
      /**
       * 清除内部文件
       * <p>/data/data/com.xxx.xxx/files</p>
       *
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanInternalFiles() {
          return FileUtil.getInstance().delete(SUtils.getApp().getFilesDir());
      }
  
      /**
       * 清除内部数据库
       * <p>/data/data/com.xxx.xxx/databases</p>
       *
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanInternalDbs() {
          return FileUtil.getInstance().delete(SUtils.getApp().getFilesDir().getParent() + File.separator + "databases");
      }
  
      /**
       * 根据名称清除数据库
       * <p>/data/data/com.xxx.xxx/databases/dbName</p>
       *
       * @param dbName 数据库名称
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanInternalDbByName(String dbName) {
          return SUtils.getApp().deleteDatabase(dbName);
      }
  
      /**
       * 清除内部 SP
       * <p>/data/data/com.xxx.xxx/shared_prefs</p>
       *
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanInternalSP() {
          return FileUtil.getInstance().delete(SUtils.getApp().getFilesDir().getParent() + File.separator + "shared_prefs");
      }
  
      /**
       * 清除外部缓存
       * <p>/storage/emulated/0/android/data/com.xxx.xxx/cache</p>
       *
       * @return {@code true}: 清除成功<br>{@code false}: 清除失败
       */
      public static boolean cleanExternalCache() {
          return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                  && FileUtil.getInstance().delete(SUtils.getApp().getExternalCacheDir());
      }
  }
  