コード例 #1
0
ファイル: HomeManager.java プロジェクト: Just-D/3DHome
 public ThemeInfo getCurrentThemeInfo() {
   ContentResolver contentResolver = getContext().getContentResolver();
   if (mCurrentThemeInfo == null) {
     String where = ThemeColumns.IS_APPLY + "=" + 1;
     Cursor cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
     if (cursor != null) {
       if (cursor.moveToFirst()) {
         mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
       }
       cursor.close();
     }
     if (mCurrentThemeInfo == null) {
       HomeUtils.markThemeAsApply(
           getContext(), HomeDataBaseHelper.getInstance(getContext()).getDefaultThemeID());
       cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
       if (cursor != null) {
         if (cursor.moveToFirst()) {
           mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
         }
         cursor.close();
       }
     }
     if (mCurrentThemeInfo == null) {
       // 数据库错误,删除数据库
       HomeUtils.deleteFile(getContext().getDatabasePath(ProviderUtils.DATABASE_NAME).getParent());
       Process.killProcess(Process.myPid());
     }
   }
   mCurrentThemeInfo.initFromXML(getContext());
   return mCurrentThemeInfo;
 }
コード例 #2
0
ファイル: HomeUtils.java プロジェクト: wljcom/3DHomeHD
 public static String deleteModelAndObjectDBByName(Context context, String name) {
   ContentResolver resolver = context.getContentResolver();
   String where = ModelColumns.OBJECT_NAME + " = '" + name + "'";
   String[] selection = {ModelColumns.PRODUCT_ID, ModelColumns.ASSETS_PATH};
   Cursor cursor = resolver.query(ModelColumns.CONTENT_URI, selection, where, null, null);
   String localPath = null;
   String productId = null;
   if (cursor != null && cursor.moveToNext()) {
     productId = cursor.getString(0);
     localPath = cursor.getString(1);
   } else {
     if (cursor != null) {
       cursor.close();
     }
     return null;
   }
   if (cursor != null) {
     cursor.close();
   }
   where = ModelColumns.OBJECT_NAME + "='" + name + "'";
   resolver.delete(ModelColumns.CONTENT_URI, where, null);
   where = ObjectInfoColumns.OBJECT_NAME + "='" + name + "'";
   resolver.delete(ObjectInfoColumns.CONTENT_URI, where, null);
   deleteFile(localPath);
   return productId;
 }
コード例 #3
0
ファイル: HomeUtils.java プロジェクト: wljcom/3DHomeHD
 public static String deleteThemeDBByProductID(Context context, String productID) {
   String where = ThemeColumns.PRODUCT_ID + " = '" + productID + "'";
   String assetPath;
   String name;
   String sceneName;
   Cursor cursor =
       context.getContentResolver().query(ThemeColumns.CONTENT_URI, null, where, null, null);
   if (cursor != null && cursor.moveToFirst()) {
     assetPath = cursor.getString(cursor.getColumnIndexOrThrow(ThemeColumns.FILE_PATH));
     name = cursor.getString(cursor.getColumnIndexOrThrow(ThemeColumns.NAME));
     sceneName = cursor.getString(cursor.getColumnIndexOrThrow(ThemeColumns.SCENE_NAME));
   } else {
     if (cursor != null) {
       cursor.close();
     }
     return null;
   }
   if (cursor != null) {
     cursor.close();
   }
   context.getContentResolver().delete(ThemeColumns.CONTENT_URI, where, null);
   if (!"home8".equals(sceneName)) {
     where = ObjectInfoColumns.SCENE_NAME + " = '" + sceneName + "'";
     context.getContentResolver().delete(ObjectInfoColumns.CONTENT_URI, where, null);
   }
   // 在老版本中资源包和wallpaper存在一个路径,假如是老版本上来的不删除这个文件夹
   if (!name.equals(new File(assetPath).getName())) deleteFile(assetPath);
   return name;
 }
コード例 #4
0
ファイル: HomeUtils.java プロジェクト: wljcom/3DHomeHD
 public static void deleteFile(String path) {
   File f = new File(path);
   if (!f.exists()) return;
   if (!(f.delete())) {
     File subs[] = f.listFiles();
     for (int i = 0; i <= subs.length - 1; i++) {
       if (subs[i].isDirectory()) deleteFile(subs[i].getAbsolutePath());
       subs[i].delete();
     }
     f.delete();
   }
 }
コード例 #5
0
ファイル: HomeUtils.java プロジェクト: wljcom/3DHomeHD
 public static void deleteWallpaperByLocalPath(Context context, String localPath) {
   deleteFile(localPath);
 }