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

The following examples show how to use android.database.Cursor#getInt() . 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: DataBaseHelper.java    From Rey-MusicPlayer with Apache License 2.0 6 votes vote down vote up
public ArrayList<Genre> searchGenre(String name) {
    ArrayList<Genre> genres = new ArrayList<>();
    String query = "SELECT * FROM " + GENRES_TABLE + " WHERE " + GENRE_NAME + " LIKE '%" + name + "%'";
    Cursor cursor = getDatabase().rawQuery(query, null);
    if (cursor != null && cursor.moveToFirst()) {
        do {
            Genre genre = new Genre(cursor.getLong(cursor.getColumnIndex(GENRE_ID)),
                    cursor.getString(cursor.getColumnIndex(GENRE_NAME)),
                    cursor.getString(cursor.getColumnIndex(GENRE_ALBUM_ART)),
                    cursor.getInt(cursor.getColumnIndex(NO_OF_ALBUMS_IN_GENRE)));
            genres.add(genre);
        } while (cursor.moveToNext());
        cursor.close();
    }
    return genres;
}
 
Example 2
Source File: DBAdapterV6.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected BookSettings createBookSettings(final Cursor c) {
    int index = 0;

    final BookSettings bs = new BookSettings(c.getString(index++));
    bs.lastUpdated = c.getLong(index++);
    bs.currentPage = new PageIndex(c.getInt(index++), c.getInt(index++));
    bs.zoom = c.getInt(index++);
    bs.viewMode = DocumentViewMode.getByOrdinal(c.getInt(index++));
    bs.pageAlign = PageAlign.values()[c.getInt(index++)];
    bs.animationType = PageAnimationType.values()[c.getInt(index++)];

    setFlags(bs, c.getLong(index++));

    bs.offsetX = c.getInt(index++) / OFFSET_FACTOR;
    bs.offsetY = c.getInt(index++) / OFFSET_FACTOR;

    bs.contrast = c.getInt(index++);
    bs.exposure = c.getInt(index++);

    return bs;
}
 
Example 3
Source File: ConversationFragment.java    From catnut with MIT License 6 votes vote down vote up
@Override
public void run() {
	String query = CatnutUtils.buildQuery(
			new String[]{"count(0)"},
			null,
			Comment.TABLE,
			null, null, null
	);
	Cursor cursor = getActivity().getContentResolver().query(
			CatnutProvider.parse(Comment.MULTIPLE),
			null,
			query,
			null, null
	);
	if (cursor.moveToNext()) {
		mTotal = cursor.getInt(0);
	}
	cursor.close();
}
 
Example 4
Source File: UserAdapter.java    From restaurant-bot with GNU General Public License v3.0 6 votes vote down vote up
public User getUser(int id) {
    SQLiteDatabase db = getReadableDatabase();
    if (db == null) {
        return null;
    }
    Cursor cursor = db.query(TABLE_USERS, PROJECTIONS_USERS, USER_ID + "=?",
            new String[]{String.valueOf(id)}, null, null, null, null);
    if (!cursor.moveToFirst()) {
        return null;
    }
    User user = new User(cursor.getInt(USER_ID_INDEX),
            cursor.getString(USER_NAME_INDEX),
            cursor.getString(USER_EMAIL_INDEX),
            cursor.getString(USER_PASSWORD_INDEX));
    cursor.close();
    return user;
}
 
Example 5
Source File: ShellScriptTable.java    From BusyBox with Apache License 2.0 6 votes vote down vote up
@Override public ShellScript onCreateObject(Cursor cursor) {
  String name = cursor.getString(cursor.getColumnIndex(Columns.NAME));
  String path = cursor.getString(cursor.getColumnIndex(Columns.PATH));
  String info = cursor.getString(cursor.getColumnIndex(Columns.INFO));
  long lastRunTime = cursor.getLong(cursor.getColumnIndex(Columns.LAST_RUN_TIME));
  boolean runAtBoot = cursor.getInt(cursor.getColumnIndex(Columns.RUN_AT_BOOT)) == 1;
  boolean runOnNetworkChange = cursor.getInt(cursor.getColumnIndex(Columns.RUN_ON_NETWORK_CHANGE)) == 1;

  ShellScript script = new ShellScript(name, path);
  script.setInfo(info);
  script.setLastRunTime(lastRunTime);
  script.setRunAtBoot(runAtBoot);
  script.setRunOnNetworkChange(runOnNetworkChange);

  return script;
}
 
Example 6
Source File: DBMusicocoController.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
@Nullable
public Sheet getSheet(int sheetId) {
    String sql = "select * from " + TABLE_SHEET + " where " + SHEET_ID + " = " + sheetId;
    Cursor cursor = database.rawQuery(sql, null);

    Sheet sheet = null;
    while (cursor.moveToNext()) {
        sheet = new Sheet();
        sheet.id = cursor.getInt(cursor.getColumnIndex(SHEET_ID));
        sheet.name = cursor.getString(cursor.getColumnIndex(SHEET_NAME));
        sheet.remark = cursor.getString(cursor.getColumnIndex(SHEET_REMARK));
        String str = cursor.getString(cursor.getColumnIndex(SHEET_CREATE));
        sheet.create = Long.valueOf(str);
        sheet.playTimes = cursor.getInt(cursor.getColumnIndex(SHEET_PLAYTIMES));
        sheet.count = cursor.getInt(cursor.getColumnIndex(SHEET_COUNT));
    }

    cursor.close();
    return sheet;
}
 
Example 7
Source File: MusicUtils.java    From Rey-MusicPlayer with Apache License 2.0 6 votes vote down vote up
public static ArrayList<Song> getSongsForCursor(Cursor cursor) {
    ArrayList<Song> songs = new ArrayList<>();
    if ((cursor != null) && (cursor.moveToFirst()))
        do {
            Song song = new Song(
                    cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media._ID)),
                    cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE)),
                    cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM)),
                    cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID)),
                    cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST)),
                    cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST_ID)),
                    cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA)),
                    cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.TRACK)),
                    cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION))
            );
            songs.add(song);
        } while (cursor.moveToNext());
    if (cursor != null)
        cursor.close();
    return songs;
}
 
Example 8
Source File: DBHelper.java    From coolreader with MIT License 6 votes vote down vote up
public int isNovelUpdated(SQLiteDatabase db, PageModel novelPage) {
	String sql = "select r.page, sum(r.hasUpdates) " +
                 "from ( select " + TABLE_NOVEL_DETAILS + "." + COLUMN_PAGE +
                 "                , case when " + TABLE_PAGE + "." + COLUMN_LAST_UPDATE + " != " + TABLE_NOVEL_CONTENT + "." + COLUMN_LAST_UPDATE +
                 "                  then 1 else 0 end as hasUpdates " +
                 "       from " + TABLE_NOVEL_DETAILS +
                 "       join " + TABLE_NOVEL_BOOK + " on " + TABLE_NOVEL_DETAILS + "." + COLUMN_PAGE + " = " + TABLE_NOVEL_BOOK + "." + COLUMN_PAGE +
                 "       join " + TABLE_PAGE + " on " + TABLE_PAGE + "." + COLUMN_PARENT + " = " + TABLE_NOVEL_DETAILS + "." + COLUMN_PAGE + " || '" + Constants.NOVEL_BOOK_DIVIDER + "' || " + TABLE_NOVEL_BOOK + "." + COLUMN_TITLE +
                 "       join " + TABLE_NOVEL_CONTENT + " on " + TABLE_NOVEL_CONTENT + "." + COLUMN_PAGE + " = " + TABLE_PAGE + "." + COLUMN_PAGE +
                 "       where " + TABLE_NOVEL_DETAILS + "." + COLUMN_PAGE + " = ? " +
                 "         and " + TABLE_PAGE + "." + COLUMN_IS_MISSING + " != 1 " +
                 ") r group by r.page ";
	Cursor cursor = rawQuery(db, sql, new String[] { novelPage.getPage() });
	try {
		cursor.moveToFirst();
		while (!cursor.isAfterLast()) {
			return cursor.getInt(1);
		}
	} finally {
		if (cursor != null)
			cursor.close();
	}

	return 0;
}
 
Example 9
Source File: MessageDatabaseService.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isMessagePresent(String key) {
    SQLiteDatabase database = dbHelper.getReadableDatabase();
    Cursor cursor = database.rawQuery(
            "SELECT COUNT(*) FROM sms WHERE keyString = ?",
            new String[]{key});
    try {
        cursor.moveToFirst();
        return cursor.getInt(0) > 0;
    } finally {
        if (cursor != null) {
            cursor.close();
            dbHelper.close();
        }
    }
}
 
Example 10
Source File: ArtistAdapter.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public void setupViewData(Cursor mCursor){

    	mLineOneText = mCursor.getString(mCursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
        int albums_plural = mCursor.getInt(mCursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_ALBUMS));
        boolean unknown = mLineOneText == null || mLineOneText.equals(MediaStore.UNKNOWN_STRING);
        mLineTwoText = MusicUtils.makeAlbumsLabel(mContext, albums_plural, 0, unknown);        
        mGridType = TYPE_ARTIST;        
        mImageData = new String[]{mLineOneText};
        mPlayingId = MusicUtils.getCurrentArtistId();
        mCurrentId = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
        
    }
 
Example 11
Source File: DBAdapterV7.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected BookSettings createBookSettings(final Cursor c) {
    int index = 0;

    final BookSettings bs = new BookSettings(c.getString(index++));
    bs.lastUpdated = c.getLong(index++);
    bs.firstPageOffset = c.getInt(index++);
    bs.currentPage = new PageIndex(c.getInt(index++), c.getInt(index++));
    bs.zoom = c.getInt(index++);
    bs.viewMode = DocumentViewMode.getByOrdinal(c.getInt(index++));
    bs.pageAlign = PageAlign.values()[c.getInt(index++)];
    bs.animationType = PageAnimationType.values()[c.getInt(index++)];

    setFlags(bs, c.getLong(index++));

    bs.offsetX = c.getInt(index++) / OFFSET_FACTOR;
    bs.offsetY = c.getInt(index++) / OFFSET_FACTOR;

    bs.contrast = c.getInt(index++);
    bs.exposure = c.getInt(index++);

    String str = c.getString(index++);
    if (LengthUtils.isNotEmpty(str)) {
        try {
            bs.typeSpecific = new JSONObject(str);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return bs;
}
 
Example 12
Source File: DBHelper.java    From BTChat with GNU General Public License v3.0 5 votes vote down vote up
public int getReportCountWithTime(int type, long timeBiggerThan, long timeSmallerThan) {
	String query = "select count(*) from " + TABLE_NAME_ACCEL_REPORT + " where " 
			+ KEY_ACCEL_TYPE + "=" + Integer.toString(type)
			+ " AND " + KEY_ACCEL_TIME + ">" + Long.toString(timeBiggerThan) 
			+ " AND " + KEY_ACCEL_TIME + "<" + Long.toString(timeSmallerThan);
	Cursor c = mDb.rawQuery(query, null);
	c.moveToFirst();
	int count = c.getInt(0);
	c.close();
	return count;
}
 
Example 13
Source File: BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java    From storio with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public BoxedTypesMethodsFactoryMethodIgnoreNull mapFromCursor(@NonNull StorIOSQLite storIOSQLite, @NonNull Cursor cursor) {

    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }

    BoxedTypesMethodsFactoryMethodIgnoreNull object = BoxedTypesMethodsFactoryMethodIgnoreNull.create(field1, field2, field3, field4, field5, field6);

    return object;
}
 
Example 14
Source File: StartActivity.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
private void getVideoFilePaths() {
    mVideoFilePaths = new ArrayList<Map<String, String>>();
    Cursor cursor;
    String[] videoColumns = {
            MediaStore.Video.Media._ID, MediaStore.Video.Media.TITLE,
            MediaStore.Video.Media.DATA, MediaStore.Video.Media.ARTIST,
            MediaStore.Video.Media.MIME_TYPE, MediaStore.Video.Media.SIZE,
            MediaStore.Video.Media.DURATION, MediaStore.Video.Media.RESOLUTION
    };
    cursor = mContext.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
            videoColumns, null, null, null);
    if (null != cursor && cursor.moveToFirst()) {
        do {
            String id = ContentTree.VIDEO_PREFIX
                    + cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
            String filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
            Map<String, String> fileInfoMap = new HashMap<String, String>();
            fileInfoMap.put(id, filePath);
            mVideoFilePaths.add(fileInfoMap);
            // Log.v(LOGTAG, "added video item " + title + "from " +
            // filePath);
        } while (cursor.moveToNext());
    }
    if (null != cursor) {
        cursor.close();
    }

}
 
Example 15
Source File: SimpleGallery.java    From NClientV2 with Apache License 2.0 4 votes vote down vote up
public SimpleGallery(Cursor c) {
    title=c.getString(c.getColumnIndex(Queries.HistoryTable.TITLE));
    id=c.getInt(c.getColumnIndex(Queries.HistoryTable.ID));
    mediaId=c.getInt(c.getColumnIndex(Queries.HistoryTable.MEDIAID));
    thumbnail=ImageExt.values()[c.getInt(c.getColumnIndex(Queries.HistoryTable.THUMB))];
}
 
Example 16
Source File: LocationsDbHelper.java    From your-local-weather with GNU General Public License v3.0 4 votes vote down vote up
public void deleteRecordFromTable(Location location) {
    int deletedOrderId = location.getOrderId();
    SQLiteDatabase db = getWritableDatabase();
    String selection = LocationsContract.Locations._ID + " = ?";
    String[] selectionArgs = {location.getId().toString()};
    db.delete(LocationsContract.Locations.TABLE_NAME, selection, selectionArgs);

    String[] projection = {
            LocationsContract.Locations._ID,
            LocationsContract.Locations.COLUMN_NAME_ORDER_ID
    };

    String sortOrder = LocationsContract.Locations.COLUMN_NAME_ORDER_ID;

    Cursor cursor = null;
    try {
        cursor = db.query(
            LocationsContract.Locations.TABLE_NAME,
            projection,
            LocationsContract.Locations.COLUMN_NAME_ORDER_ID + ">" + deletedOrderId,
            null,
            null,
            null,
            sortOrder
        );

        while (cursor.moveToNext()) {
            long itemId = cursor.getInt(cursor.getColumnIndexOrThrow(LocationsContract.Locations._ID));
            int orderId = cursor.getInt(cursor.getColumnIndexOrThrow(LocationsContract.Locations.COLUMN_NAME_ORDER_ID));
            ContentValues values = new ContentValues();
            values.put(LocationsContract.Locations.COLUMN_NAME_ORDER_ID, orderId - 1);
            db.updateWithOnConflict(
                    LocationsContract.Locations.TABLE_NAME,
                    values,
                    LocationsContract.Locations._ID +"=" + itemId,
                    null,
                    SQLiteDatabase.CONFLICT_IGNORE);
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
Example 17
Source File: MessageDatabaseService.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static Message getMessage(Cursor cursor) {
    Message message = new Message();
    message.setMessageId(cursor.getLong(cursor.getColumnIndex("id")));
    message.setKeyString(cursor.getString(cursor.getColumnIndex("keyString")));
    message.setType(cursor.getShort(cursor.getColumnIndex("type")));
    message.setSource(cursor.getShort(cursor.getColumnIndex("source")));
    Long storeOnDevice = cursor.getLong(cursor.getColumnIndex("storeOnDevice"));
    message.setStoreOnDevice(storeOnDevice != null && storeOnDevice.intValue() == 1);
    String contactNumbers = cursor.getString(cursor.getColumnIndex("contactNumbers"));
    message.setContactIds(contactNumbers);
    message.setCreatedAtTime(cursor.getLong(cursor.getColumnIndex("createdAt")));
    Long delivered = cursor.getLong(cursor.getColumnIndex("delivered"));
    message.setDelivered(delivered != null && delivered.intValue() == 1);

    Long canceled = cursor.getLong(cursor.getColumnIndex("canceled"));
    message.setCanceled(canceled != null && canceled.intValue() == 1);

    Long read = cursor.getLong(cursor.getColumnIndex("read"));
    message.setRead(read != null && read.intValue() == 1);

    message.setStatus(cursor.getShort(cursor.getColumnIndex(MobiComDatabaseHelper.STATUS)));
    message.setClientGroupId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.CLIENT_GROUP_ID)));

    Long scheduledAt = cursor.getLong(cursor.getColumnIndex("scheduledAt"));
    message.setScheduledAt(scheduledAt == null || scheduledAt.intValue() == 0 ? null : scheduledAt);
    message.setMessage(cursor.getString(cursor.getColumnIndex("message")));
    Long sentToServer = cursor.getLong(cursor.getColumnIndex("sentToServer"));
    message.setSentToServer(sentToServer != null && sentToServer.intValue() == 1);
    message.setTo(cursor.getString(cursor.getColumnIndex("toNumbers")));
    int timeToLive = cursor.getInt(cursor.getColumnIndex("timeToLive"));
    message.setReplyMessage(cursor.getInt(cursor.getColumnIndex("replyMessage")));
    message.setTimeToLive(timeToLive != 0 ? timeToLive : null);
    String fileMetaKeyStrings = cursor.getString(cursor.getColumnIndex("fileMetaKeyStrings"));
    if (!TextUtils.isEmpty(fileMetaKeyStrings)) {
        message.setFileMetaKeyStrings(fileMetaKeyStrings);
    }
    String filePaths = cursor.getString(cursor.getColumnIndex("filePaths"));
    if (!TextUtils.isEmpty(filePaths)) {
        message.setFilePaths(Arrays.asList(filePaths.split(",")));
    }
    message.setHidden(cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.HIDDEN)) == 1);
    String metadata = cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.MESSAGE_METADATA));
    if (!TextUtils.isEmpty(metadata)) {
        message.setMetadata(((Map<String, String>) GsonUtils.getObjectFromJson(metadata, Map.class)));
    }
    message.setApplicationId(cursor.getString(cursor.getColumnIndex("applicationId")));
    message.setContentType(cursor.getShort(cursor.getColumnIndex(MobiComDatabaseHelper.MESSAGE_CONTENT_TYPE)));
    int conversationId = cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CONVERSATION_ID));
    if (conversationId == 0) {
        message.setConversationId(null);
    } else {
        message.setConversationId(conversationId);
    }
    message.setTopicId(cursor.getString(cursor.getColumnIndex(MobiComDatabaseHelper.TOPIC_ID)));
    int channelKey = cursor.getInt(cursor.getColumnIndex(MobiComDatabaseHelper.CHANNEL_KEY));
    if (channelKey == 0) {
        message.setGroupId(null);
    } else {
        message.setGroupId(channelKey);
    }

    if (cursor.getString(cursor.getColumnIndex("blobKeyString")) == null) {
        //file is not present...  Don't set anything ...
    } else {
        FileMeta fileMeta = new FileMeta();
        fileMeta.setKeyString(cursor.getString(cursor.getColumnIndex("metaFileKeyString")));
        fileMeta.setBlobKeyString(cursor.getString(cursor.getColumnIndex("blobKeyString")));
        fileMeta.setThumbnailBlobKey(cursor.getString(cursor.getColumnIndex("thumbnailBlobKey")));
        fileMeta.setThumbnailUrl(cursor.getString(cursor.getColumnIndex("thumbnailUrl")));
        fileMeta.setSize(cursor.getInt(cursor.getColumnIndex("size")));
        fileMeta.setName(cursor.getString(cursor.getColumnIndex("name")));
        fileMeta.setContentType(cursor.getString(cursor.getColumnIndex("contentType")));
        fileMeta.setUrl(cursor.getString(cursor.getColumnIndex("url")));
        message.setFileMetas(fileMeta);
    }
    return message;
}
 
Example 18
Source File: MainActivity.java    From CarbonContacts with MIT License 4 votes vote down vote up
public void readPhoneContacts(Context context)
{   phoneContacts.clear();
    Cursor cursor = context.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    Integer contactsCount = cursor.getCount(); //get how many contacts you have in your contacts list
    if (contactsCount > 0)
    {
        while(cursor.moveToNext())
        {
            String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            if (Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
            {
                //the below cursor will give you details for multiple contacts
                Cursor pCursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,
                        ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
                        new String[]{id}, null);
                // continue till this cursor reaches to all phone numbers which are associated with a contact in the contact list
                while (pCursor.moveToNext())
                {
                    int phoneType = pCursor.getInt(pCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
                    //String isStarred = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.STARRED));
                    String phoneNo 	= pCursor.getString(pCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                    //you will get all phone numbers according to it's type as below switch case.
                    //Logs.e will print the phone number along with the name in DDMS. you can use these details where ever you want.
                    String phoneNumberID = pCursor.getString(pCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID));
                    String type = null;

                    switch (phoneType)
                    {
                        case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
                            type = "M";
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
                            type = "H";
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
                            type = "W";
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE:
                            type = "WM";
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER:
                            type = "O";
                            break;
                        default:
                            break;
                    }
                    if(!whatsAppIDs.contains(phoneNumberID))
                        phoneContacts.add(new PhoneContact(phoneNo, contactName, type, id, phoneNumberID));
                    Log.i("Contact details:",phoneNo + ": " + contactName + ": " + type + ": " + id + ": " + phoneNumberID);
                    Log.i("contacts type:", pCursor.getString(pCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.ACCOUNT_TYPE_AND_DATA_SET)));
                }
                pCursor.close();
            }
        }
        cursor.close();
    }
}
 
Example 19
Source File: ImageAdapter.java    From recent-images with MIT License 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	int id = cursor.getInt(IMAGE_ID_COLUMN);
	((ImageView) view).setImageDrawable(getCachedThumbnailAsync(
			ContentUris.withAppendedId(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, id)));
}
 
Example 20
Source File: BooleanType.java    From QuantumFlux with Apache License 2.0 4 votes vote down vote up
@Override
public Object getColumnValue(Cursor cursor, int columnIndex) {
    return cursor.getInt(columnIndex) == 0 ? Boolean.FALSE : Boolean.TRUE;
}