Cursor moveToPosition - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Cursor moveToPosition method.

This code example shows how to use the following methods:getString, moveToPosition
    setListAdapter(new BookmarkAdapter(this, cursor));
  } 
 
  @Override 
  protected void onListItemClick(ListView l, View view, int position, long id) {
    if (cursor.moveToPosition(position)) {
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
      intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
      setResult(RESULT_OK, intent);
    } else { 
      setResult(RESULT_CANCELED);
    } 
    finish();
  } 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColumnIndexOrThrow, getString, isAfterLast, moveToPosition
                args, R.string.user_dict_settings_add_dialog_title, null, null, 0);
    } 
 
    private String getWord(final int position) {
        if (null == mCursor) return null;
        mCursor.moveToPosition(position);
        // Handle a possible race-condition 
        if (mCursor.isAfterLast()) return null;
 
        return mCursor.getString(
                mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD));
    } 
 
    private String getShortcut(final int position) {
        if (null == mCursor) return null;
        mCursor.moveToPosition(position);
        // Handle a possible race-condition 
        if (mCursor.isAfterLast()) return null;
 
        return mCursor.getString(

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getCount, moveToPosition
	public Map<String, Contact> getContacts(int offset, int max_results, List<String> select, Map<String, Object> conditions) throws Exception {
		Map<String, Contact> contacts = new HashMap<String, Contact>();
		 
		Cursor cursor = cr.query(People.CONTENT_URI, null, null, null, null);
		try { 
			if (!cursor.moveToPosition(offset))
				return contacts;
			if (max_results == -1) {
				max_results = cursor.getCount() - offset;
			} 
			 
			do { 
				if(contacts.size() >= max_results) {
					break; 
				} 
				Contact contact = new Contact();
	 
				String id = cursor.getString(cursor.getColumnIndex(People._ID));
				contact.setId(id);
	 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getString, moveToPosition
    setListAdapter(new BookmarkAdapter(this, cursor));
  } 
 
  @Override 
  protected void onListItemClick(ListView l, View view, int position, long id) {
    if (cursor.moveToPosition(position)) {
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
      intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
      setResult(RESULT_OK, intent);
    } else { 
      setResult(RESULT_CANCELED);
    } 
    finish();
  } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:moveToPosition
    @Override 
    public Object instantiateItem(View container, int position) {
        if (!mDataValid) {
            throw new IllegalStateException("this should only be called when the cursor is valid");
        } 
        if (!mCursor.moveToPosition(position)) {
            throw new IllegalStateException("couldn't move cursor to position " + position);
        } 
 
        View v = newView(mContext, mCursor, (ViewGroup) container);
        bindView(v, mContext, mCursor);
 
        ((ViewPager) container).addView(v);
 
        return v;
    } 
 
    @Override 
    public void destroyItem(View container, int position, Object object) {
        ((ViewPager) container).removeView((View) object);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColumnIndexOrThrow, getString, moveToPosition
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id)
    { 
        Intent intent = new Intent(Intent.ACTION_VIEW);
        mCursor.moveToPosition(position);
        String type = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
        intent.setDataAndType(ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, id), type);
         
        startActivity(intent);
    } 
 
    private void MakeCursor() { 
        String[] cols = new String[] {
                MediaStore.Video.Media._ID,
                MediaStore.Video.Media.TITLE,
                MediaStore.Video.Media.DATA,
                MediaStore.Video.Media.MIME_TYPE,
                MediaStore.Video.Media.ARTIST
        }; 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getCount, getPosition, isAfterLast, isBeforeFirst, moveToFirst
		return cursor.getColumnName(column - 1);
	} 
 
	@Override 
    public int getColumnType(int column) throws SQLException {
        int oldPos = cursor.getPosition();
        boolean moved = false;
        if (cursor.isBeforeFirst() || cursor.isAfterLast()) {
            boolean resultSetEmpty = cursor.getCount() == 0 || cursor.isAfterLast();
            if (resultSetEmpty) {
                return Types.NULL;
            } 
            cursor.moveToFirst();
            moved = true;
        } 
        int nativeType = getType(cursor, column - 1);
        int type;
        switch (nativeType) {
        case 0: // Cursor.FIELD_TYPE_NULL: 
            type = Types.NULL;

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBlob, getColumnIndexOrThrow, getLong, moveToPosition
 
    public static final String TIME = "time";
    public static final String VALUE = "value";
 
    public static GenericObservation observationFromCursor(final Cursor c, int pos) {
		c.moveToPosition(pos);
		 
		final GenericObservation observation = new GenericObservation(
				c.getLong(c.getColumnIndexOrThrow(OBSERVATION_TYPE_ID)),
				c.getLong(c.getColumnIndexOrThrow(TIME)),
				c.getBlob(c.getColumnIndexOrThrow(VALUE)));
				 
		return observation;
	} 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getCount, getString, moveToPosition
 
		Cursor cursor = mDb.rawQuery(slq, null);
 
		String returnStr = " ";
 
		if (cursor.getCount() > 0) {
			cursor.moveToPosition(0);
			returnStr = cursor.getString(0);
		} 
		cursor.close();
 
		return returnStr;
	} 
 
	/** 
	 * 특정 노선 하행선 가져 오기 
	 *  
	 * @param nosun 
	 * @return 
	 */ 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getColumnIndex, getString, moveToPosition

Related Cursor moveToPosition Questions & Answers:

moveToPosition Method Overview
Move the cursor to an absolute position.
See Code Examples for other Android Cursor Methods: