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

The following examples show how to use android.database.Cursor#getPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemShoppingListCursorAdapter.java    From ShoppingList with MIT License 6 votes vote down vote up
public String[] getDescriptions() {
    Cursor c = getCursor();
    if (c != null) {
        String[] descriptions = new String[c.getCount()];

        for (int i = 0; i < c.getCount(); i++) {
            c.moveToPosition(i);
            ItemShoppingList itemShoppingList = getItem(c.getPosition());

            descriptions[c.getPosition()] = itemShoppingList.getDescription();
        }

        return descriptions;
    }

    return new String[]{};
}
 
Example 2
Source File: DatabaseHelper.java    From android_dbinspector with Apache License 2.0 6 votes vote down vote up
/**
 * Compat method so we can get type of column on API < 11.
 * Source: http://stackoverflow.com/a/20685546/2643666
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static int getColumnType(Cursor cursor, int col) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
        CursorWindow cursorWindow = sqLiteCursor.getWindow();
        int pos = cursor.getPosition();
        int type = -1;
        if (cursorWindow.isNull(pos, col)) {
            type = FIELD_TYPE_NULL;
        } else if (cursorWindow.isLong(pos, col)) {
            type = FIELD_TYPE_INTEGER;
        } else if (cursorWindow.isFloat(pos, col)) {
            type = FIELD_TYPE_FLOAT;
        } else if (cursorWindow.isString(pos, col)) {
            type = FIELD_TYPE_STRING;
        } else if (cursorWindow.isBlob(pos, col)) {
            type = FIELD_TYPE_BLOB;
        }
        return type;
    } else {
        return cursor.getType(col);
    }
}
 
Example 3
Source File: LabelUtils.java    From HeartBeat with Apache License 2.0 6 votes vote down vote up
private static long[] getRelativedIds(Context context, String idField, String getField, long id) {
    Cursor cursor = DatabaseUtils.query(
            context, EventLabelRelationTable.NAME,
            new String[]{EventLabelRelationTable.EVENT_ID, EventLabelRelationTable.LABEL_ID},
            idField + "=?",
            new String[]{String.valueOf(id)});
    if (cursor.getCount() < 1) {
        cursor.close();
        return new long[] {};
    }
    long[] ret = new long[cursor.getCount()];
    while (cursor.moveToNext()) {
        ret[cursor.getPosition()] = DatabaseUtils.getLong(cursor, getField);
    }
    cursor.close();
    return ret;
}
 
Example 4
Source File: AlarmSettingItemListAdapter.java    From SpecialAlarmClock with Apache License 2.0 6 votes vote down vote up
public AlarmSettingItemListAdapter(Context context, Alarm alarm) {
    this.context = (context);

    Log.d("AlarmSettingItemListAdapter", "Loading Ringtones...");

    RingtoneManager ringtoneMgr = new RingtoneManager(getContext());
    ringtoneMgr.setType(RingtoneManager.TYPE_ALARM);
    Cursor alarmsCursor = ringtoneMgr.getCursor();
    alarmTones = new String[alarmsCursor.getCount() + 1];
    alarmTones[0] = "静默模式";
    alarmTonePaths = new String[alarmsCursor.getCount() + 1];
    alarmTonePaths[0] = "";
    if (alarmsCursor.moveToFirst()) {
        do {
            Log.d("ITEM", ringtoneMgr.getRingtone(alarmsCursor.getPosition()).getTitle(getContext()));
            Log.d("ITEM", ringtoneMgr.getRingtoneUri(alarmsCursor.getPosition()).toString());
            alarmTones[alarmsCursor.getPosition() + 1] = ringtoneMgr.getRingtone(alarmsCursor.getPosition()).getTitle(getContext());
            alarmTonePaths[alarmsCursor.getPosition() + 1] = ringtoneMgr.getRingtoneUri(alarmsCursor.getPosition()).toString();
        } while (alarmsCursor.moveToNext());
    }
    Log.d("AlarmSettingItemListAdapter", "Finished Loading " + alarmTones.length + " Ringtones.");
    alarmsCursor.close();
    setMathAlarm(alarm);
}
 
Example 5
Source File: ImageList.java    From droidddle with Apache License 2.0 6 votes vote down vote up
@Override
protected BaseImage loadImageFromCursor(Cursor cursor) {
    long id = cursor.getLong(INDEX_ID);
    String dataPath = cursor.getString(INDEX_DATA_PATH);
    long dateTaken = cursor.getLong(INDEX_DATE_TAKEN);
    if (dateTaken == 0) {
        dateTaken = cursor.getLong(INDEX_DATE_MODIFIED) * 1000;
    }
    long miniThumbMagic = cursor.getLong(INDEX_MINI_THUMB_MAGIC);
    int orientation = cursor.getInt(INDEX_ORIENTATION);
    String title = cursor.getString(INDEX_TITLE);
    String mimeType = cursor.getString(INDEX_MIME_TYPE);
    if (title == null || title.length() == 0) {
        title = dataPath;
    }
    return new Image(this, mContentResolver, id, cursor.getPosition(), contentUri(id), dataPath, mimeType, dateTaken, title, orientation);
}
 
Example 6
Source File: SQLiteAndroidDatabase.java    From AvI with MIT License 6 votes vote down vote up
private void bindPreHoneycomb(JSONObject row, String key, Cursor cursor, int i) throws JSONException {
    // Since cursor.getType() is not available pre-honeycomb, this is
    // a workaround so we don't have to bind everything as a string
    // Details here: http://stackoverflow.com/q/11658239
    SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
    CursorWindow cursorWindow = sqLiteCursor.getWindow();
    int pos = cursor.getPosition();
    if (cursorWindow.isNull(pos, i)) {
        row.put(key, JSONObject.NULL);
    } else if (cursorWindow.isLong(pos, i)) {
        row.put(key, cursor.getLong(i));
    } else if (cursorWindow.isFloat(pos, i)) {
        row.put(key, cursor.getDouble(i));
    /* ** Read BLOB as Base-64 DISABLED in this branch:
    } else if (cursorWindow.isBlob(pos, i)) {
        row.put(key, new String(Base64.encode(cursor.getBlob(i), Base64.DEFAULT)));
    // ** Read BLOB as Base-64 DISABLED to HERE. */
    } else { // string
        row.put(key, cursor.getString(i));
    }
}
 
Example 7
Source File: ConnectionListFragment.java    From MongoExplorer with MIT License 6 votes vote down vote up
private void selectItem(Cursor cursor, long id) {
	int pos = 0;
	int original = cursor.getPosition();
	if (!cursor.moveToFirst())
		return;

	do {
		if (cursor.getLong(MongoBrowserProvider.INDEX_CONNECTION_ID) == id)
			break;
		pos++;
	} while (cursor.moveToNext());
	
	cursor.moveToPosition(original);

       setActivatedPosition(pos);
}
 
Example 8
Source File: FileLoaderCallbacks.java    From MultiType-FilePicker with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void onAudioResult(Cursor data) {
    List<Directory<AudioFile>> directories = new ArrayList<>();

    if (data.getPosition() != -1) {
        data.moveToPosition(-1);
    }

    while (data.moveToNext()) {
        //Create a File instance
        AudioFile audio = new AudioFile();
        audio.setId(data.getLong(data.getColumnIndexOrThrow(_ID)));
        audio.setName(data.getString(data.getColumnIndexOrThrow(TITLE)));
        audio.setPath(data.getString(data.getColumnIndexOrThrow(DATA)));
        audio.setSize(data.getLong(data.getColumnIndexOrThrow(SIZE)));
        audio.setDate(data.getLong(data.getColumnIndexOrThrow(DATE_ADDED)));

        audio.setDuration(data.getLong(data.getColumnIndexOrThrow(DURATION)));

        //Create a Directory
        Directory<AudioFile> directory = new Directory<>();
        directory.setName(Util.extractFileNameWithSuffix(Util.extractPathWithoutSeparator(audio.getPath())));
        directory.setPath(Util.extractPathWithoutSeparator(audio.getPath()));

        if (!directories.contains(directory)) {
            directory.addFile(audio);
            directories.add(directory);
        } else {
            directories.get(directories.indexOf(directory)).addFile(audio);
        }
    }

    if (resultCallback != null) {
        resultCallback.onResult(directories);
    }
}
 
Example 9
Source File: AddContactActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
private int searchInitListPos(Cursor c, String listName) {
    if (TextUtils.isEmpty(listName)) {
        return 0;
    }
    c.moveToPosition(-1);
    while (c.moveToNext()) {
        if (listName.equals(c.getString(CONTACT_LIST_NAME_COLUMN))) {
            return c.getPosition();
        }
    }
    return 0;
}
 
Example 10
Source File: TopAndRecentlyPlayedTracksLoader.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@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 11
Source File: SmsContentObserver.java    From smscode-auto-reader with MIT License 5 votes vote down vote up
private void querySms() {

        final Uri uri = Uri.parse("content://sms/inbox");
        ContentResolver contentResolver = context.getContentResolver();
        final String[] projection = { "body", "_id", "date" };
        String sqlWhere = getSqlWhere();
        if (sqlWhere == null || sqlWhere.equals("")) {
            return;
        }
        Cursor cursor = null;
        try {
            cursor = contentResolver.query(uri, projection, sqlWhere, null, null);
            int i = -1;
            long time = 0;
            while (cursor.moveToNext()) {
                long smsDate = cursor.getLong(2);
                if (smsDate > time) {
                    time = smsDate;
                    i = cursor.getPosition();
                }
            }

            String observedVerifyNum;
            if (i >= 0) {
                cursor.moveToPosition(i);
                String smsBody = cursor.getString(cursor.getColumnIndex("body"));
                observedVerifyNum = getVerifyNumFromSms(smsBody);
                callback.onReceived(observedVerifyNum);
            } else {
                callback.onReceived(null);
            }

        } catch (Exception exception) {
            Log.e(TAG, "querySms error");
        } finally {
            if (cursor != null && !cursor.isClosed()) {
                cursor.close();
            }
        }
    }
 
Example 12
Source File: FileLoaderCallbacks.java    From MultiType-FilePicker with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void onVideoResult(final Cursor data) {
    List<Directory<VideoFile>> directories = new ArrayList<>();

    if (data.getPosition() != -1) {
        data.moveToPosition(-1);
    }

    while (data.moveToNext()) {
        //Create a File instance
        VideoFile video = new VideoFile();
        video.setId(data.getLong(data.getColumnIndexOrThrow(_ID)));
        video.setName(data.getString(data.getColumnIndexOrThrow(TITLE)));
        video.setPath(data.getString(data.getColumnIndexOrThrow(DATA)));
        video.setSize(data.getLong(data.getColumnIndexOrThrow(SIZE)));
        video.setBucketId(data.getString(data.getColumnIndexOrThrow(BUCKET_ID)));
        video.setBucketName(data.getString(data.getColumnIndexOrThrow(BUCKET_DISPLAY_NAME)));
        video.setDate(data.getLong(data.getColumnIndexOrThrow(DATE_ADDED)));

        video.setDuration(data.getLong(data.getColumnIndexOrThrow(DURATION)));

        //Create a Directory
        Directory<VideoFile> directory = new Directory<>();
        directory.setId(video.getBucketId());
        directory.setName(video.getBucketName());
        directory.setPath(Util.extractPathWithoutSeparator(video.getPath()));

        if (!directories.contains(directory)) {
            directory.addFile(video);
            directories.add(directory);
        } else {
            directories.get(directories.indexOf(directory)).addFile(video);
        }
    }

    if (resultCallback != null) {
        resultCallback.onResult(directories);
    }
}
 
Example 13
Source File: TopAndRecentlyPlayedTracksLoader.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@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 14
Source File: EventSelectionFragment.java    From attendee-checkin with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the position of the specified event in this adapter.
 *
 * @param eventId The event ID.
 * @return The position of the specified event, or -1 when not found.
 */
public int findPosition(String eventId) {
    if (eventId == null) {
        return -1;
    }
    Cursor cursor = getCursor();
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
        if (TextUtils.equals(eventId,
                cursor.getString(cursor.getColumnIndexOrThrow(Table.Event.ID)))) {
            return cursor.getPosition();
        }
    }
    return -1;
}
 
Example 15
Source File: OCursorListAdapter.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
public View getCachedView(Cursor cr) {
    int pos = cr.getPosition();
    if (mViewCache.size() > pos) {
        return mViewCache.get("view_" + pos);
    }
    return null;
}
 
Example 16
Source File: TopAndRecentlyPlayedSongsLoader.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@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 songs 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 TopSongsCursor to handle sorting given order
            return new SortedLongCursor(songCursor, order, BaseColumns._ID);
        }
    }

    return null;
}
 
Example 17
Source File: SearchView.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
/**
 * 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 18
Source File: ProfilWeightCursorAdapter.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {

    CardView cdView = view.findViewById(R.id.CARDVIEW);


    if (cursor.getPosition() % 2 == mFirstColorOdd) {
        cdView.setBackgroundColor(context.getResources().getColor(R.color.record_background_even));
    } else {
        cdView.setBackgroundColor(context.getResources().getColor(R.color.background));
    }

    TextView t1 = view.findViewById(R.id.DATE_CELL);
    Date date;
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        date = dateFormat.parse(cursor.getString(1));

        //SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        //dateFormat2.setTimeZone(TimeZone.getTimeZone("GMT"));
        //t1.setText(dateFormat2.format(date));
        DateFormat dateFormat3 = android.text.format.DateFormat.getDateFormat(mContext.getApplicationContext());
        dateFormat3.setTimeZone(TimeZone.getTimeZone("GMT"));
        t1.setText(dateFormat3.format(date));
    } catch (ParseException e) {
        t1.setText("");
        e.printStackTrace();
    }

    TextView t2 = view.findViewById(R.id.WEIGHT_CELL);
    //t2.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(2))));
    t2.setText(cursor.getString(2));

    ImageView deletImg = view.findViewById(R.id.deleteButton);
    deletImg.setTag(cursor.getLong(0));
    deletImg.setOnClickListener(v -> {
        if (mDeleteClickListener != null)
            mDeleteClickListener.onBtnClick((long) v.getTag());
    });

}
 
Example 19
Source File: MainActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 4 votes vote down vote up
private void listing10_18() {
  // Call Log reading requires a runtime permission.
  if (ActivityCompat.checkSelfPermission(this,
    Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
    ActivityCompat.requestPermissions(this,
      new String[]{Manifest.permission.READ_CONTACTS},
      CONTACTS_PERMISSION_REQUEST);
    return;
  }

  // Listing 10-18: Accessing the Call Log Content Provider
  // Create a projection that limits the result Cursor
  // to the required columns.
  String[] projection = {
    CallLog.Calls.DURATION,
    CallLog.Calls.NUMBER,
    CallLog.Calls.CACHED_NAME,
    CallLog.Calls.TYPE
  };

  // Return only outgoing calls.
  String where = CallLog.Calls.TYPE + "=?";
  String[] whereArgs = {String.valueOf(CallLog.Calls.OUTGOING_TYPE)};

  // Get a Cursor over the Call Log Calls Provider.
  Cursor cursor =
    getContentResolver().query(CallLog.Calls.CONTENT_URI,
      projection, where, whereArgs, null);

  // Get the index of the columns.
  int durIdx = cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION);
  int numberIdx = cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER);
  int nameIdx = cursor.getColumnIndexOrThrow(CallLog.Calls.CACHED_NAME);

  // Initialize the result set.
  String[] result = new String[cursor.getCount()];

  // Iterate over the result Cursor.
  while (cursor.moveToNext()) {
    String durStr = cursor.getString(durIdx);
    String numberStr = cursor.getString(numberIdx);
    String nameStr = cursor.getString(nameIdx);
    result[cursor.getPosition()] = numberStr + " for " + durStr + "sec" +
                                     ((null == nameStr) ?
                                        "" : " (" + nameStr + ")");
    Log.d(TAG, result[cursor.getPosition()]);
  }

  // Close the Cursor.
  cursor.close();
}
 
Example 20
Source File: BodyMeasureCursorAdapter.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView t0 = view.findViewById(R.id.LIST_BODYMEASURE_ID);
    t0.setText(cursor.getString(0));

    TextView t1 = view.findViewById(R.id.LIST_BODYMEASURE_DATE);
    Date date;
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        date = dateFormat.parse(cursor.getString(1));

        //SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        //dateFormat2.setTimeZone(TimeZone.getTimeZone("GMT"));
        //t1.setText(DateFormat.getDateInstance().format(date));
        DateFormat dateFormat3 = getDateFormat(mContext.getApplicationContext());
        dateFormat3.setTimeZone(TimeZone.getTimeZone("GMT"));
        t1.setText(dateFormat3.format(date));
    } catch (ParseException e) {
        t1.setText("");
        e.printStackTrace();
    }

    TextView t2 = view.findViewById(R.id.LIST_BODYMEASURE_WEIGHT);
    t2.setText(cursor.getString(3));

    CardView cdView = view.findViewById(R.id.CARDVIEW);

    int mFirstColorOdd = 0;
    if (cursor.getPosition() % 2 == mFirstColorOdd) {
        cdView.setBackgroundColor(context.getResources().getColor(R.color.record_background_even));
    } else {
        cdView.setBackgroundColor(context.getResources().getColor(R.color.background));
    }

    ImageView deletImg = view.findViewById(R.id.deleteButton);
    deletImg.setTag(cursor.getLong(0));
    deletImg.setOnClickListener(v -> {
        if (mDeleteClickListener != null)
            mDeleteClickListener.onBtnClick((long) v.getTag());
    });

}