get Id Set from provider BaseColumns - Android android.provider

Android examples for android.provider:BaseColumns

Description

get Id Set from provider BaseColumns

Demo Code


//package com.java2s;
import java.util.HashSet;
import java.util.Set;

import android.database.Cursor;

import android.provider.BaseColumns;

public class Main {
    public static Set<Long> getIdSet(Cursor c) {
        Set<Long> ids = new HashSet<Long>();
        if (c.moveToFirst()) {
            do {/*  w  w w.  j  av a 2  s.  co  m*/
                ids.add(c.getLong(c.getColumnIndex(BaseColumns._ID)));
            } while (c.moveToNext());
        }
        return ids;
    }
}

Related Tutorials