From e40086d2abf4fb65941765f5a653b1f42f9ecffd Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Fri, 5 May 2017 18:56:27 +0200 Subject: [PATCH] Add counting magic Signed-off-by: Mario Danic --- .../datamodel/FilesystemDataProvider.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java index e275498e8e..2688ee6ede 100644 --- a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java +++ b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java @@ -40,6 +40,27 @@ public class FilesystemDataProvider { this.contentResolver = contentResolver; } + public long countFilesThatNeedUploadInFolder(String localPath) { + String likeParam = localPath + "%"; + + Cursor cursor = contentResolver.query( + ProviderMeta.ProviderTableMeta.CONTENT_URI_FILESYSTEM, + new String[] {"count(*)"}, + ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH + " LIKE ?", + new String[]{likeParam}, + null); + + if (cursor.getCount() == 0) { + cursor.close(); + return 0; + } else { + cursor.moveToFirst(); + int result = cursor.getInt(0); + cursor.close(); + return result; + } + } + public void storeOrUpdateFileValue(String localPath, long modifiedAt, boolean isFolder, boolean sentForUpload) { FileSystemDataSet data = getFilesystemDataSet(localPath);