Refine search
private Uri getVideoUri(int position) { videos.moveToPosition(position); return(ContentUris.withAppendedId( MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videos.getInt( videos.getColumnIndex(MediaStore.Video.Media._ID)))); } }
@Override public void onBindViewHolder(GuestViewHolder holder, int position) { // Move the mCursor to the position of the item to be displayed if (!mCursor.moveToPosition(position)) return; // bail if returned null // Update the view holder with the information needed to display String name = mCursor.getString(mCursor.getColumnIndex(WaitlistContract.WaitlistEntry.COLUMN_GUEST_NAME)); int partySize = mCursor.getInt(mCursor.getColumnIndex(WaitlistContract.WaitlistEntry.COLUMN_PARTY_SIZE)); // Display the guest name holder.nameTextView.setText(name); // Display the party count holder.partySizeTextView.setText(String.valueOf(partySize)); }
// This is the content uri for the BadgeProvider Uri uri = Uri.parse("content://com.sec.badge/apps"); Cursor c = getContentResolver().query(uri, null, null, null, null); // This indicates the provider doesn't exist and you probably aren't running // on a Samsung phone running TWLauncher. This has to be outside of try/finally block if (c == null) { return; } try { if (!c.moveToFirst()) { // No results. Nothing to query return; } c.moveToPosition(-1); while (c.moveToNext()) { String pkg = c.getString(1); String clazz = c.getString(2); int badgeCount = c.getInt(3); Log.d("BadgeTest", "package: " + pkg + ", class: " + clazz + ", count: " + String.valueOf(cnt)); } } finally { c.close(); }
@SuppressWarnings("deprecation") Cursor imagecursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy); int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID); this.count = imagecursor.getCount(); this.arrPath = new String[this.count]; ids = new int[count]; this.thumbnailsselection = new boolean[this.count]; for (int i = 0; i < this.count; i++) { imagecursor.moveToPosition(i); ids[i] = imagecursor.getInt(image_column_index); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); arrPath[i] = imagecursor.getString(dataColumnIndex);
MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount()); source.moveToPosition(-1); while (source.moveToNext()) { MatrixCursor.RowBuilder row = cursor.newRow(); for (int i = 0; i < columnNames.length; i++) { row.add(source.getString(i));
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ContentResolver contentResolver = getContentResolver(); Cursor curRawContacts = contentResolver.query(ContactsContract.RawContacts.CONTENT_URI, null, ContactsContract.RawContacts.ACCOUNT_TYPE + " = ? AND " + ContactsContract.RawContacts.ACCOUNT_NAME + " = ?", new String[]{"MYTYPE", MyAccount}, null); int size = curRawContacts.getCount(); for (int i = 0; i < size; i++) { curRawContacts.moveToPosition(i); //getColumnIndexOrThrow(String columnName) //Returns the zero-based index for the given column name, or throws IlleidRawContactgalArgumentException if the column doesn 't exist. String idRawContact = curRawContacts.getString(curRawContacts.getColumnIndexOrThrow(ContactsContract.RawContacts._ID)); String idContact = curRawContacts.getString(curRawContacts.getColumnIndexOrThrow(ContactsContract.RawContacts.CONTACT_ID)); // if link to aggregated contact is null, than raw contact had already been deleted if (idContact != null) {
return (dataCursor == null) ? 0 : dataCursor.getCount(); dataCursor.moveToPosition(position);
public void selectRandomImage(boolean small) { Cursor c = getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null); if (c != null) { int count = c.getCount(); if (c.moveToPosition(position)) { long id = c.getLong(c.getColumnIndex(Images.Media._ID)); Uri imageUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + id);
super.onListItemClick(l, v, position, id); Cursor c = mNotesCursor; c.moveToPosition(position); Intent i = new Intent(this, NoteEdit.class); i.putExtra(NotesDbAdapter.KEY_ROWID, id); i.putExtra(NotesDbAdapter.KEY_TITLE, c.getString( c.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); i.putExtra(NotesDbAdapter.KEY_BODY, c.getString( c.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY))); startActivityForResult(i, ACTIVITY_EDIT);
public ArrayList<YourObject> getYourObjects(){ ArrayList<YourObject> yourObject= new ArrayList<YourObject>(); SQLiteDatabase db=this.getReadableDatabase(); Cursor cur=db.rawQuery("YOUR QUERY",new String [] {}); for(int i = 0; i<cur.getCount(); i++){ cur.moveToPosition(i); String string.setTimeInMillis(cur.getLong(cur.getColumnIndexOrThrow("YOUR_COLLUMN_NAME"))); yourObject.add(new YourObject()); } cur.close(); db.close(); return workObjects; }
public Person get(int position) { Cursor cursor = getCursor(); Person person; if(cursor.moveToPosition(position)) { person = new Person(); person.id = cursor.getLong(cursor.getColumnIndex("_id")); person.firstName = cursor.getString(cursor.getColumnIndex("firstName")); person.surname = cursor.getString(cursor.getColumnIndex("surname")); results.add(person); } return person; }
Cursor cursor = this.getContentResolver().query( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, // Which columns to return null, // Return all rows null, "image_id DESC"); // Get the column index of the Thumbnails Image ID int columnIndex = cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA); for(int i =0;i<cursor.getCount();i++){ if (i==100) break; cursor.moveToPosition(i); mImagesFromGallery[i] = cursor.getString(columnIndex); } cursor.close();
@Override public void bindView(View view, Context context, final Cursor cursor) { // TODO Auto-generated method stub TextView tv1 = (TextView)view.findViewById(R.id.txt_name); TextView tv2 = (TextView)view.findViewById(R.id.txt_numer); tv1.setText(cursor.getString(2)); tv2.setText(cursor.getString(3)); final Button call_btn= (Button)view.findViewById(R.id.call_btn); final int position = cursor.getPosition(); call_btn.setOnClickListener(new Button.OnClickListener(){ @Override public void onClick(View v) { cursor.moveToPosition(position); Toast.makeText(b, cursor.getString(1), Toast.LENGTH_SHORT).show(); }}); }
... DataBaseHelper db = new DataBaseHelper(this); ... db.open(); Cursor cursor = db.getAllItems(); maxCount = cursor.getCount(); Random gen = new Random(); row = gen.nextInt(maxCount); // Generate random between 0 and max if (cursor.moveToPosition(row)) { String myString = cursor.getString(1); //here I want the second column displayString(myString); //private method } cursor.close(); db.close();
private Uri getVideoUri(int position) { videos.moveToPosition(position); return(ContentUris.withAppendedId( MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videos.getInt(videos.getColumnIndex(MediaStore.Video.Media._ID)))); } }
SearchHistoryColumns.TIMESEARCHED + " ASC"); if (oldest != null && oldest.getCount() > MAX_ITEMS_IN_DB) { oldest.moveToPosition(oldest.getCount() - MAX_ITEMS_IN_DB); long timeOfRecordToKeep = oldest.getLong(0);
db.open(); Cursor c = db.getautobackupSettings(session.getUserId()); if(c.getCount()>0) { c.moveToPosition(0); int camerabackup = c.getInt(c.getColumnIndex("your colomn name")); } db.close
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //get details about the clicked note CursorAdapter ca = (CursorAdapter) parent.getAdapter(); Cursor c = ca.getCursor(); c.moveToPosition(position); displayRestoreDialog(c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_ID)), c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_NAME)), c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_CONTENT)), c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_TYPE))); } });
@Override public void onBindViewHolder(GuestViewHolder holder, int position) { // COMPLETED (5) Move the cursor to the passed in position, return if moveToPosition returns false // Move the mCursor to the position of the item to be displayed if (!mCursor.moveToPosition(position)) return; // bail if returned null // COMPLETED (6) Call getString on the cursor to get the guest's name String name = mCursor.getString(mCursor.getColumnIndex(WaitlistContract.WaitlistEntry.COLUMN_GUEST_NAME)); // COMPLETED (7) Call getInt on the cursor to get the party size int partySize = mCursor.getInt(mCursor.getColumnIndex(WaitlistContract.WaitlistEntry.COLUMN_PARTY_SIZE)); // COMPLETED (8) Set the holder's nameTextView text to the guest's name // Display the guest name holder.nameTextView.setText(name); // COMPLETED (9) Set the holder's partySizeTextView text to the party size // Display the party count holder.partySizeTextView.setText(String.valueOf(partySize)); }
final String orderBy = MediaStore.Images.Media.DATE_TAKEN; Cursor imagecursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns,null,null, orderBy + " DESC"); this.imageUrls = new ArrayList<String>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); imageUrls.add(imagecursor.getString(dataColumnIndex)); System.out.println("==here you will get all the images path ;=> "+imageUrls.get(i)); }