Java Code Examples for android.database.Cursor.getPosition()

The following are Jave code examples for showing how to use getPosition() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: mobile-store   File: LoggingQuery.java   Source Code and License Vote up 8 votes
private String[] getExplainQueryPlan() {
    Cursor cursor = db.rawQuery("EXPLAIN QUERY PLAN " + query, queryArgs);
    String[] plan = new String[cursor.getCount()];
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        // The docs at https://sqlite.org/eqp.html talk about how the output format of
        // EXPLAIN QUERY PLAN can change between SQLite versions. This has been observed
        // between the sqlite versions on Android 2.3.3 and Android 5.0. However, it seems
        // that the last column is always the one with the interesting details that we wish
        // to log. If this fails for some reason, then hey, it is only for debug builds, right?
        if (cursor.getColumnCount() > 0) {
            int index = cursor.getColumnCount() - 1;
            plan[cursor.getPosition()] = cursor.getString(index);
        }
        cursor.moveToNext();
    }
    cursor.close();
    return plan;
}
 
Example 2
Project: simple-share-android   File: FilteringCursorWrapper.java   Source Code and License Vote up 6 votes
public FilteringCursorWrapper(
        Cursor cursor, String[] acceptMimes, String[] rejectMimes, long rejectBefore) {
    mCursor = cursor;

    final int count = cursor.getCount();
    mPosition = new int[count];

    cursor.moveToPosition(-1);
    while (cursor.moveToNext() && mCount < count) {
        final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
        final String name = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME);
        final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
        if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
            continue;
        }
        if (lastModified < rejectBefore) {
            continue;
        }

        if (MimePredicate.mimeMatches(acceptMimes, mimeType)) {
            mPosition[mCount++] = cursor.getPosition();
        }
    }

    Log.d(TAG, "Before filtering " + cursor.getCount() + ", after " + mCount);
}
 
Example 3
Project: easyfilemanager   File: FilteringCursorWrapper.java   Source Code and License Vote up 6 votes
public FilteringCursorWrapper(
        Cursor cursor, String[] acceptMimes, String[] rejectMimes, long rejectBefore) {
    mCursor = cursor;

    final int count = cursor.getCount();
    mPosition = new int[count];

    cursor.moveToPosition(-1);
    while (cursor.moveToNext() && mCount < count) {
        final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
        final String name = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME);
        final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
        if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
            continue;
        }
        if (lastModified < rejectBefore) {
            continue;
        }

        if (MimePredicate.mimeMatches(acceptMimes, mimeType)) {
            mPosition[mCount++] = cursor.getPosition();
        }
    }

    Log.d(TAG, "Before filtering " + cursor.getCount() + ", after " + mCount);
}
 
Example 4
Project: FireFiles   File: FilteringCursorWrapper.java   Source Code and License Vote up 6 votes
public FilteringCursorWrapper(
        Cursor cursor, String[] acceptMimes, String[] rejectMimes, long rejectBefore) {
    mCursor = cursor;

    final int count = cursor.getCount();
    mPosition = new int[count];

    cursor.moveToPosition(-1);
    while (cursor.moveToNext() && mCount < count) {
        final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
        final String name = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME);
        final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
        if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
            continue;
        }
        if (lastModified < rejectBefore) {
            continue;
        }

        if (MimePredicate.mimeMatches(acceptMimes, mimeType)) {
            mPosition[mCount++] = cursor.getPosition();
        }
    }

    Log.d(TAG, "Before filtering " + cursor.getCount() + ", after " + mCount);
}
 
Example 5
Project: Android-Scrapper   File: DatabaseDump.java   Source Code and License Vote up 6 votes
private JSONArray exportTable(String tableName) throws JSONException {

        // get everything from the table
        String sql = "select * from " + tableName;
        Cursor cur = mDatabase.rawQuery(sql, new String[0]);
        int numCols = cur.getColumnCount();
        JSONArray resultSet = new JSONArray();
        cur.moveToFirst();

        // move through the table, creating rows
        // and adding each column with name and value
        // to the row
        while (cur.getPosition() < cur.getCount()) {
            JSONObject rowObject = new JSONObject();
            for (int idx = 0; idx < numCols; idx++) {
                rowObject.put(cur.getColumnName(idx), cur.getString(idx));
            }

            resultSet.put(rowObject);
            cur.moveToNext();
        }

        cur.close();
        return resultSet;
    }
 
Example 6
Project: mobile-store   File: ValueObject.java   Source Code and License Vote up 5 votes
void checkCursorPosition(Cursor cursor) throws IllegalArgumentException {
    if (cursor.getPosition() == -1) {
        throw new IllegalArgumentException(
            "Cursor position is -1. " +
            "Did you forget to moveToFirst() or move() before passing to the value object?");
    }
}
 
Example 7
Project: PeSanKita-android   File: SmsMigrator.java   Source Code and License Vote up 5 votes
public static void migrateDatabase(Context context,
                                     MasterSecret masterSecret,
                                     SmsMigrationProgressListener listener)
  {
//    if (context.getSharedPreferences("SecureSMS", Context.MODE_PRIVATE).getBoolean("migrated", false))
//      return;

    ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
    Cursor cursor                 = null;

    try {
      Uri threadListUri = Uri.parse("content://mms-sms/conversations?simple=true");
      cursor            = context.getContentResolver().query(threadListUri, null, null, null, "date ASC");

      while (cursor != null && cursor.moveToNext()) {
        long   theirThreadId         = cursor.getLong(cursor.getColumnIndexOrThrow("_id"));
        String theirRecipients       = cursor.getString(cursor.getColumnIndexOrThrow("recipient_ids"));
        Recipients ourRecipients     = getOurRecipients(context, theirRecipients);
        ProgressDescription progress = new ProgressDescription(cursor.getCount(), cursor.getPosition(), 100, 0);

        if (ourRecipients != null) {
          long ourThreadId = threadDatabase.getThreadIdFor(ourRecipients);
          migrateConversation(context, masterSecret,
                              listener, progress,
                              theirThreadId, ourThreadId);
        }

        progress.incrementPrimaryComplete();
        listener.progressUpdate(progress);
      }
    } finally {
      if (cursor != null)
        cursor.close();
    }

    context.getSharedPreferences("SecureSMS", Context.MODE_PRIVATE).edit()
      .putBoolean("migrated", true).apply();
  }
 
Example 8
Project: OftenPorter   File: TypeUtil.java   Source Code and License Vote up 5 votes
private static int getType(Cursor cursor, int columnIndex) throws Exception
{

    if (Build.VERSION.SDK_INT >= 11)
    {
        return cursor.getType(columnIndex);
    }

    SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
    CursorWindow cursorWindow = sqLiteCursor.getWindow();
    int pos = cursor.getPosition();
    int type = -1;
    if (cursorWindow.isNull(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_NULL;
    } else if (cursorWindow.isLong(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_INTEGER;
    } else if (cursorWindow.isFloat(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_FLOAT;
    } else if (cursorWindow.isString(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_STRING;
    } else if (cursorWindow.isBlob(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_BLOB;
    }

    return type;
}
 
Example 9
Project: CSipSimple   File: CallLogAdapter.java   Source Code and License Vote up 5 votes
/**
 * Returns the call types for the given number of items in the cursor.
 * <p>
 * It uses the next {@code count} rows in the cursor to extract the types.
 * <p>
 * It position in the cursor is unchanged by this function.
 */
private int[] getCallTypes(Cursor cursor, int count) {
    int position = cursor.getPosition();
    int[] callTypes = new int[count];
    for (int index = 0; index < count; ++index) {
        callTypes[index] = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE));
        cursor.moveToNext();
    }
    cursor.moveToPosition(position);
    return callTypes;
}
 
Example 10
Project: CSipSimple   File: CallLogAdapter.java   Source Code and License Vote up 5 votes
/**
 * Returns the call ids for the given number of items in the cursor.
 * <p>
 * It uses the next {@code count} rows in the cursor to extract the types.
 * <p>
 * It position in the cursor is unchanged by this function.
 */
private long[] getCallIds(Cursor cursor, int count) {
    int position = cursor.getPosition();
    long[] callIds = new long[count];
    for (int index = 0; index < count; ++index) {
        if(!cursor.isAfterLast()) {
            callIds[index] = cursor.getLong(cursor.getColumnIndex(CallLog.Calls._ID));
        }
        cursor.moveToNext();
    }
    cursor.moveToPosition(position);
    return callIds;
}
 
Example 11
Project: CSipSimple   File: SearchView.java   Source Code and License Vote up 5 votes
/**
 * When a particular suggestion has been selected, perform the various lookups required
 * to use the suggestion.  This includes checking the cursor for suggestion-specific data,
 * and/or falling back to the XML for defaults;  It also creates REST style Uri data when
 * the suggestion includes a data id.
 *
 * @param c The suggestions cursor, moved to the row of the user's selection
 * @param actionKey The key code of the action key that was pressed,
 *        or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
 * @param actionMsg The message for the action key that was pressed,
 *        or <code>null</code> if none.
 * @return An intent for the suggestion at the cursor's position.
 */
private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
    try {
        // use specific action if supplied, or default action if supplied, or fixed default
        String action = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_ACTION);

        if (action == null) {
            action = mSearchable.getSuggestIntentAction();
        }
        if (action == null) {
            action = Intent.ACTION_SEARCH;
        }

        // use specific data if supplied, or default data if supplied
        String data = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA);
        if (data == null) {
            data = mSearchable.getSuggestIntentData();
        }
        // then, if an ID was provided, append it.
        if (data != null) {
            String id = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
            if (id != null) {
                data = data + "/" + Uri.encode(id);
            }
        }
        Uri dataUri = (data == null) ? null : Uri.parse(data);

        String query = getColumnString(c, SearchManager.SUGGEST_COLUMN_QUERY);
        String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);

        return createIntent(action, dataUri, extraData, query, actionKey, actionMsg);
    } catch (RuntimeException e ) {
        int rowNum;
        try {                       // be really paranoid now
            rowNum = c.getPosition();
        } catch (RuntimeException e2 ) {
            rowNum = -1;
        }
        Log.w(LOG_TAG, "Search suggestions cursor at row " + rowNum +
                        " returned exception.", e);
        return null;
    }
}
 
Example 12
Project: Orin   File: TopAndRecentlyPlayedTracksLoader.java   Source Code and License Vote up 5 votes
@Nullable
private static SortedLongCursor makeSortedCursor(@NonNull final Context context, @Nullable final Cursor cursor, final int idColumn) {
    if (cursor != null && cursor.moveToFirst()) {
        // create the list of ids to select against
        StringBuilder selection = new StringBuilder();
        selection.append(BaseColumns._ID);
        selection.append(" IN (");

        // this tracks the order of the ids
        long[] order = new long[cursor.getCount()];

        long id = cursor.getLong(idColumn);
        selection.append(id);
        order[cursor.getPosition()] = id;

        while (cursor.moveToNext()) {
            selection.append(",");

            id = cursor.getLong(idColumn);
            order[cursor.getPosition()] = id;
            selection.append(String.valueOf(id));
        }

        selection.append(")");

        // get a list of songs with the data given the selection statement
        Cursor songCursor = SongLoader.makeSongCursor(context, selection.toString(), null);
        if (songCursor != null) {
            // now return the wrapped TopTracksCursor to handle sorting given order
            return new SortedLongCursor(songCursor, order, BaseColumns._ID);
        }
    }

    return null;
}
 
Example 13
Project: financisto1-holo   File: Utils.java   Source Code and License Vote up 5 votes
public static int moveCursor(Cursor cursor, String idColumnName, long id) {
       int pos = cursor.getColumnIndexOrThrow(idColumnName);
       if (cursor.moveToFirst()) {
           do {
               if (cursor.getLong(pos) == id) {
                   return cursor.getPosition();
               }
           } while(cursor.moveToNext());
       }
	return -1;
}
 
Example 14
Project: KomaMusic   File: SongsPresenter.java   Source Code and License Vote up 5 votes
/**
 * 根据包含song id的cursor,获取排序好的song cursor
 *
 * @param context
 * @param cursor
 * @param idColumn
 * @return
 */
public static SortedCursor makeSortedCursor(final Context context, final Cursor cursor,
                                            final int idColumn) {
    if (cursor != null && cursor.moveToFirst()) {

        StringBuilder selection = new StringBuilder();
        selection.append(BaseColumns._ID);
        selection.append(" IN (");

        long[] order = new long[cursor.getCount()];

        long id = cursor.getLong(idColumn);
        selection.append(id);
        order[cursor.getPosition()] = id;

        while (cursor.moveToNext()) {
            selection.append(",");

            id = cursor.getLong(idColumn);
            order[cursor.getPosition()] = id;
            selection.append(String.valueOf(id));
        }

        selection.append(")");

        Cursor songCursor = makeSongCursor(context, selection.toString(), null);
        if (songCursor != null) {
            return new SortedCursor(songCursor, order, BaseColumns._ID, null);
        }
    }

    if (cursor != null) {
        cursor.close();
    }

    return null;
}
 
Example 15
Project: NoticeDog   File: InboxCursorAdapter.java   Source Code and License Vote up 5 votes
void initConversationView(final Context context, Cursor cursor, final InboxConversationView conversationView, Conversation conversation, boolean isExpanded) {
    conversationView.setAppId(conversation.getLastMessage().getAppId());
    conversationView.setAppSpecificSenderId(conversation.getSender().getAppSpecificUserId());
    conversationView.setFrom(conversation.getSender().getDisplayName());
    conversationView.setMessagePreview(conversation.getLastMessage().getBody());
    conversationView.setTimestamp(conversation.getLastMessage().getTimestamp());
    conversationView.setNumUnreadMessages(conversation.getNumUnreadMessages());
    App app = this.appManager.getAppById(conversation.getLastMessage().getAppId());
    Drawable icon = app.getAppIcon();
    ProfilePhoto profilePhoto = app.getProfilePhotoForMessage(conversation.getLastMessage());
    conversationView.setProfilePhoto(context, profilePhoto);
    if (profilePhoto == null) {
        ((ProfilePhotoManager) GuiceModule.get().getInstance(ProfilePhotoManager.class)).loadProfilePhoto(conversation.getSender().getAppId(), conversation.getSender().getAppSpecificUserId(), conversation.getSender().getDisplayName(), new ProfilePhotoManager.OnProfilePhotoLoadedListener() {
            public void onProfilePhotoLoaded(String appId, String senderId, String senderName, ProfilePhoto photo) {
                if (InboxCursorAdapter.this.areStringsEqual(appId, conversationView.getAppId()) && InboxCursorAdapter.this.areStringsEqual(senderId, conversationView.getAppSpecificSenderId()) && InboxCursorAdapter.this.areStringsEqual(senderName, conversationView.getFrom())) {
                    conversationView.setProfilePhoto(context, photo);
                }
            }
        });
    }
    conversationView.setIcon(icon);
    int index = cursor.getPosition();
    boolean showAllMessagesDivider = false;
    if (index == 0 && conversation.getNumUnreadMessages() <= 0) {
        this.firstReadConversation = conversation.getLastMessage().getTimestamp();
    } else if (index > 0 && conversation.getNumUnreadMessages() <= 0 && conversation.getLastMessage().getTimestamp() >= this.firstReadConversation) {
        this.firstReadConversation = conversation.getLastMessage().getTimestamp();
        showAllMessagesDivider = true;
    }
    conversationView.showAllMessagesDivider(showAllMessagesDivider);
}
 
Example 16
Project: RetroMusicPlayer   File: TopAndRecentlyPlayedTracksLoader.java   Source Code and License Vote up 5 votes
@Nullable
private static SortedLongCursor makeSortedCursor(@NonNull final Context context, @Nullable final Cursor cursor, final int idColumn) {

    if (cursor != null && cursor.moveToFirst()) {
        // create the list of ids to select against
        StringBuilder selection = new StringBuilder();
        selection.append(BaseColumns._ID);
        selection.append(" IN (");

        // this tracks the order of the ids
        long[] order = new long[cursor.getCount()];

        long id = cursor.getLong(idColumn);
        selection.append(id);
        order[cursor.getPosition()] = id;

        while (cursor.moveToNext()) {
            selection.append(",");

            id = cursor.getLong(idColumn);
            order[cursor.getPosition()] = id;
            selection.append(String.valueOf(id));
        }

        selection.append(")");

        // get a list of songs with the data given the selection statement
        Cursor songCursor = SongLoader.makeSongCursor(context, selection.toString(), null);
        if (songCursor != null) {
            // now return the wrapped TopTracksCursor to handle sorting given order
            return new SortedLongCursor(songCursor, order, BaseColumns._ID);
        }
    }

    return null;
}
 
Example 17
Project: Android-DFU-App   File: UARTConfigurationsAdapter.java   Source Code and License Vote up 5 votes
public int getItemPosition(final long id) {
	final Cursor cursor = getCursor();
	if (cursor == null)
		return 1;

	if (cursor.moveToFirst())
		do {
			if (cursor.getLong(0 /* _ID */) == id)
				return cursor.getPosition() + 1;
		} while (cursor.moveToNext());
	return 1; // should never happen
}
 
Example 18
Project: Cable-Android   File: SmsMigrator.java   Source Code and License Vote up 5 votes
public static void migrateDatabase(Context context,
                                     MasterSecret masterSecret,
                                     SmsMigrationProgressListener listener)
  {
//    if (context.getSharedPreferences("SecureSMS", Context.MODE_PRIVATE).getBoolean("migrated", false))
//      return;

    ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
    Cursor cursor                 = null;

    try {
      Uri threadListUri = Uri.parse("content://mms-sms/conversations?simple=true");
      cursor            = context.getContentResolver().query(threadListUri, null, null, null, "date ASC");

      while (cursor != null && cursor.moveToNext()) {
        long   theirThreadId         = cursor.getLong(cursor.getColumnIndexOrThrow("_id"));
        String theirRecipients       = cursor.getString(cursor.getColumnIndexOrThrow("recipient_ids"));
        Recipients ourRecipients     = getOurRecipients(context, theirRecipients);
        ProgressDescription progress = new ProgressDescription(cursor.getCount(), cursor.getPosition(), 100, 0);

        if (ourRecipients != null) {
          long ourThreadId = threadDatabase.getThreadIdFor(ourRecipients);
          migrateConversation(context, masterSecret,
                              listener, progress,
                              theirThreadId, ourThreadId);
        }

        progress.incrementPrimaryComplete();
        listener.progressUpdate(progress);
      }
    } finally {
      if (cursor != null)
        cursor.close();
    }

    context.getSharedPreferences("SecureSMS", Context.MODE_PRIVATE).edit()
      .putBoolean("migrated", true).apply();
  }
 
Example 19
Project: CSipSimple   File: ConversationsAdapter.java   Source Code and License Vote up 4 votes
@Override
public void bindView(View view, Context context, Cursor cursor) {
    super.bindView(view, context, cursor);

    final ConversationListItemViews tagView = (ConversationListItemViews) view.getTag();
    String nbr = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM));
    String fromFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
    String to_number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO));
    
    //int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ));
    long date = cursor.getLong(cursor.getColumnIndex(SipMessage.FIELD_DATE));
    
    
    tagView.fromFull = fromFull;
    tagView.to = to_number;
    tagView.from = nbr;
    tagView.position = cursor.getPosition();
    
    
    /*
    Drawable background = (read == 0)?
            context.getResources().getDrawable(R.drawable.conversation_item_background_unread) :
            context.getResources().getDrawable(R.drawable.conversation_item_background_read);
    
    view.setBackgroundDrawable(background);
     */
    String number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
    CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, number);
    
    /*
    final Uri lookupUri = info.contactContentUri;
    final String name = info.name;
    final int ntype = info.numberType;
    final String label = info.phoneLabel;
    CharSequence formattedNumber = SipUri.getCanonicalSipContact(number, false);
    */
    
    
    // Photo
    tagView.quickContactView.assignContactUri(info.contactContentUri);
    ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, 
            tagView.quickContactView.getImageView(),
            info,
            R.drawable.ic_contact_picture_holo_dark);

    // From
    tagView.fromView.setText(formatMessage(cursor));

    //Date
    // Set the date/time field by mixing relative and absolute times.
    int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
    tagView.dateView.setText(DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags));
}
 
Example 20
Project: filepicker   File: ImagePickerModel.java   Source Code and License Vote up 4 votes
private List<Folder> onLoadImages(Cursor cursor) {
    if (cursor.getPosition() != -1) {
        cursor.moveToPosition(-1);
    }
    List<Folder> folders = new ArrayList<>();
    List<ImageFile> imageFiles = new ArrayList<>();
    while (cursor.moveToNext()) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(cursor.getString(cursor.getColumnIndexOrThrow(DATA)), options);
        if (options.outMimeType == null) {
            continue;
        }
        ImageFile img = new ImageFile();
        long id = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
        img.setId(id);
        img.setName(cursor.getString(cursor.getColumnIndexOrThrow(TITLE)));
        img.setPath(cursor.getString(cursor.getColumnIndexOrThrow(DATA)));
        img.setSize(cursor.getLong(cursor.getColumnIndexOrThrow(SIZE)));
        img.setBucketId(cursor.getString(cursor.getColumnIndexOrThrow(BUCKET_ID)));
        img.setBucketName(cursor.getString(cursor.getColumnIndexOrThrow(BUCKET_DISPLAY_NAME)));
        img.setDate(cursor.getLong(cursor.getColumnIndexOrThrow(DATE_ADDED)));
        img.setOrientation(cursor.getInt(cursor.getColumnIndexOrThrow(ORIENTATION)));
        imageFiles.add(img);
        //Create a Folder
        Folder folder = new Folder();
        folder.setId(img.getBucketId());
        folder.setName(img.getBucketName());
        folder.setPath(Util.extractDirectory(img.getPath()));

        if (!folders.contains(folder)) {
            folder.setCoverPath(img.getPath());
            folder.addFile(img);
            folders.add(folder);
        } else {
            folders.get(folders.indexOf(folder)).addFile(img);
        }
    }
    ImagePickerConfig config = (ImagePickerConfig) FilePicker.getPickerConfig();
    if(config.isNeedEdit()){
        for(ImageFile imageFile:imageFiles){
            mImageDao.find(imageFile);
        }
    }
    Folder all = new Folder();
    all.setName(mContext.getString(R.string.all));
    all.setFiles(imageFiles);
    all.setSelected(true);
    folders.add(0, all);
    return folders;
}