Take a look at MediaColumns.TITLE 29.03.2011 0:47 пользователь "snowcrash" <[email protected]> написал: > I'm facing the following problem while implementing a ContentProvider > to deliver images stored in the private data area of an application in > an android-project: > > The files returned by the implementation below have the complete > absolute path to the stored images as filename which look like > > _data_data_com.mypackage.imageprovider_app_images_123456789.jpg > > where app_images is the name of the directory the images are stored in > by the application and 123456789.jpg is the actual filename. > > My question now is: How can I make the ContentProvider set only the > actual filename (or alternatively a filename I specify) for the > delivered images? > > It should be possible, since e.g. the built-in providers in android > manage to deliver only the actual filename for an image. > > The database table has columns for _id, filename and _data, where > _data holds the absolute path to the image in the filesystem. > > Any hints are very highly appreciated :) > > Thanks in advance, 131071 > > Here are the relevant parts of my current ContentProvider: > > @Override > public Cursor query(Uri uri, String[] projection, String selection, > String[] selectionArgs, String sortOrder) > { > final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); > queryBuilder.setTables(PhotosTable.TABLE_NAME); > > switch (URI_MATCHER.match(uri)) > { > case PHOTO_DIR: > if (sortOrder == null) > { > sortOrder = PhotosDirectory.DEFAULT_SORT_ORDER; > } > break; > > case PHOTO_ID: > queryBuilder.appendWhere(IPhotoColumns.FILENAME + "=" > + uri.getPathSegments().get(1) + " AND "); > break; > > default: > throw new IllegalArgumentException("Unknown URI " + uri); > } > > if (!mDb.isOpen()) > { > assignWritableDb(); > } > > return queryBuilder.query(mDb, PhotosDirectory.ALL_COLUMNS, > selection, selectionArgs, null, null, sortOrder); > } > > > @Override > public ParcelFileDescriptor openFile(Uri uri, String mode) > { > if (URI_MATCHER.match(uri) != PHOTO_ID) > { > throw new IllegalArgumentException( > "operation only permitted for single file"); > } > try > { > return openFileHelper(uri, mode); > } > catch (FileNotFoundException e) > { > return null; > } > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

