+ private int updateFolderSize(SQLiteDatabase db, String folderId) {
+ int count = 0;
+ Uri selectUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, folderId);
+ String[] selectProjection = new String[] { ProviderTableMeta.FILE_CONTENT_LENGTH };
+ String selectWhere = ProviderTableMeta.FILE_PARENT + "=?";
+ String updateWhere = ProviderTableMeta._ID + "=?";
+ String [] whereArgs = new String[] { folderId };
+ Cursor childrenLengths = query(db, selectUri, selectProjection, selectWhere, whereArgs, null);
+ if (childrenLengths != null && childrenLengths.moveToFirst()) {
+ long size = 0;
+ while (!childrenLengths.isAfterLast()) {
+ size += childrenLengths.getLong(childrenLengths.getColumnIndex(ProviderTableMeta.FILE_CONTENT_LENGTH));
+ childrenLengths.moveToNext();
+ }
+ ContentValues cv = new ContentValues();
+ cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, size);
+ count = db.update(ProviderTableMeta.DB_NAME, cv, updateWhere, whereArgs);
+ }
+ return count;
+ }
+
+