Example #1
0
 public static int searchMaxIndex(SEScene scene, String table, String name) {
   String where =
       ObjectInfoColumns.SCENE_NAME
           + "='"
           + scene.getSceneName()
           + "' AND "
           + ObjectInfoColumns.OBJECT_NAME
           + "='"
           + name
           + "'";
   Context context = HomeManager.getInstance().getContext();
   Cursor cursor =
       HomeDataBaseHelper.getInstance(context)
           .getReadableDatabase()
           .query(
               table,
               new String[] {"max(" + ObjectInfoColumns.OBJECT_INDEX + ") as max_index"},
               where,
               null,
               null,
               null,
               null);
   if (cursor != null && cursor.moveToFirst()) {
     int max_index = cursor.getInt(0);
     cursor.close();
     return max_index;
   }
   return 0;
 }
Example #2
0
 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;
 }