本文整理汇总了Java中android.provider.MediaStore.Files.FileColumns类的典型用法代码示例。如果您正苦于以下问题:Java FileColumns类的具体用法?Java FileColumns怎么用?Java FileColumns使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileColumns类属于android.provider.MediaStore.Files包,在下文中一共展示了FileColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEmpty
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private boolean isEmpty(Uri uri, String type) {
final ContentResolver resolver = getContext().getContentResolver();
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
String[] mimeType;
if (TYPE_DOCUMENT_ROOT.equals(type)) {
mimeType = DOCUMENT_MIMES;
} else if (TYPE_ARCHIVE_ROOT.equals(type)) {
mimeType = ARCHIVE_MIMES;
} else if (TYPE_APK_ROOT.equals(type)) {
mimeType = APK_MIMES;
} else {
return true;
}
cursor = resolver.query(FILE_URI,
FileQuery.PROJECTION,
FileColumns.MIME_TYPE + " IN "+ "("+toString(mimeType)+")" , null, null);
return (cursor == null) || (cursor.getCount() == 0);
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
}
示例2: onMediaStoreInsert
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
/**
* When inserting the first item of each type, we need to trigger a roots
* refresh to clear a previously reported {@link Root#FLAG_EMPTY}.
*/
static void onMediaStoreInsert(Context context, String volumeName, int type, long id) {
if (!"external".equals(volumeName)) return;
if (type == FileColumns.MEDIA_TYPE_IMAGE && sReturnedImagesEmpty) {
sReturnedImagesEmpty = false;
notifyRootsChanged(context);
} else if (type == FileColumns.MEDIA_TYPE_VIDEO && sReturnedVideosEmpty) {
sReturnedVideosEmpty = false;
notifyRootsChanged(context);
} else if (type == FileColumns.MEDIA_TYPE_AUDIO && sReturnedAudioEmpty) {
sReturnedAudioEmpty = false;
notifyRootsChanged(context);
}
}
示例3: queryFile
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private void queryFile(ContentResolver resolver, Cursor cursor, MatrixCursor result, String[] mimeType, String like) {
// single file
cursor = resolver.query(FILE_URI,
FileQuery.PROJECTION,
FileColumns.MIME_TYPE + " IN "+ "("+toString(mimeType)+")"
+ " OR " + FileColumns.MIME_TYPE + " LIKE "+ "'"+like+"%'",
null,
null);
copyNotificationUri(result, FILE_URI);
while (cursor.moveToNext()) {
includeFile(result, cursor);
}
}
示例4: queryRecentFile
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private void queryRecentFile(ContentResolver resolver, Cursor cursor, MatrixCursor result, String[] mimeType) {
// single file
cursor = resolver.query(FILE_URI,
FileQuery.PROJECTION, FileColumns.MIME_TYPE + " IN "+ "("+toString(mimeType)+")" , null,
FileQuery.DATE_MODIFIED + " DESC");
copyNotificationUri(result, FILE_URI);
while (cursor.moveToNext() && result.getCount() < 64) {
includeFile(result, cursor);
}
}
示例5: loadBucketEntriesFromFilesTable
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private static BucketEntry[] loadBucketEntriesFromFilesTable(
ThreadPool.JobContext jc, ContentResolver resolver, int type) {
Uri uri = getFilesContentUri();
Cursor cursor = resolver.query(uri,
PROJECTION_BUCKET, BUCKET_GROUP_BY,
null, BUCKET_ORDER_BY);
if (cursor == null) {
Log.w(TAG, "cannot open local database: " + uri);
return new BucketEntry[0];
}
ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
int typeBits = 0;
if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_IMAGE);
}
if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_VIDEO);
}
try {
while (cursor.moveToNext()) {
if ((typeBits & (1 << cursor.getInt(INDEX_MEDIA_TYPE))) != 0) {
BucketEntry entry = new BucketEntry(
cursor.getInt(INDEX_BUCKET_ID),
cursor.getString(INDEX_BUCKET_NAME));
if (!buffer.contains(entry)) {
buffer.add(entry);
}
}
if (jc.isCancelled()) return null;
}
} finally {
Utils.closeSilently(cursor);
}
return buffer.toArray(new BucketEntry[buffer.size()]);
}
示例6: loadBucketEntries
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
public static BucketEntry[] loadBucketEntries(Path path, ThreadPool.JobContext jc, Context mContext) {
Uri uri = mBaseUri;
Log.v("DebugLoadingTime", "start quering media provider");
Cursor cursor = mContext.getContentResolver().query(
uri, PROJECTION_BUCKET, BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);
if (cursor == null) {
Log.w(TAG, "cannot open local database: " + uri);
return new BucketEntry[0];
}
ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
int typeBits = 0;
int mType = getTypeFromPath(path);
if ((mType & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_IMAGE);
}
if ((mType & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_VIDEO);
}
try {
while (cursor.moveToNext()) {
if ((typeBits & (1 << cursor.getInt(INDEX_MEDIA_TYPE))) != 0) {
BucketEntry entry = new BucketEntry(
cursor.getInt(INDEX_BUCKET_ID),
cursor.getString(INDEX_BUCKET_NAME));
if (!buffer.contains(entry)) {
buffer.add(entry);
}
}
if (jc.isCancelled()) return null;
}
Log.v("DebugLoadingTime", "got " + buffer.size() + " buckets");
} finally {
cursor.close();
}
return buffer.toArray(new BucketEntry[buffer.size()]);
}
示例7: Job
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
public Job(String path, String id) {
mPath = path;
mId = id;
mMft = ArchosMediaFile.getFileType(path);
// default mime type / media type
int mediaType = FileColumns.MEDIA_TYPE_NONE;
String mimeType = "application/octet-stream";
boolean retrieve = false;
if (mMft != null) {
mimeType = mMft.mimeType;
if (!isNoMediaPath(path)) {
if (ArchosMediaFile.isAudioFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_AUDIO;
retrieve = true;
} else if (ArchosMediaFile.isVideoFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_VIDEO;
} else if (ArchosMediaFile.isImageFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_IMAGE;
} else if (ArchosMediaFile.isPlayListFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_PLAYLIST;
}
}
}
mMimeType = mimeType;
mMediaType = mediaType;
mRetrieve = retrieve;
}
示例8: processVideoNamesInDB
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private void processVideoNamesInDB(SQLiteDatabase db) {
Cursor c = db.query(FILES_TABLE_NAME, new String[] {MediaColumns.DATA, "_id"}, "media_type like " + FileColumns.MEDIA_TYPE_VIDEO, null, null, null, null);
if (c == null) {
return;
}
while (c.moveToNext()) {
String path = c.getString(0);
long id = c.getLong(1);
ContentValues cvExtra = VideoNameProcessor.extractValuesFromPath(path);
db.update(FILES_TABLE_NAME, cvExtra, SELECTION_ID, new String[] { String.valueOf(id) });
}
}
示例9: Job
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
public Job(String path, String id, Blacklist blacklist) {
mPath = Uri.parse(path);
mId = id;
mMft = ArchosMediaFile.getFileType(path);
// default mime type / media type
int mediaType = FileColumns.MEDIA_TYPE_NONE;
String mimeType = "application/octet-stream";
boolean retrieve = false;
if (mMft != null) {
mimeType = mMft.mimeType;
if (!isNoMediaPath(path) && !blacklist.isBlacklisted(mPath)) {
if (ArchosMediaFile.isAudioFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_AUDIO;
} else if (ArchosMediaFile.isVideoFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_VIDEO;
retrieve = true;
} else if (ArchosMediaFile.isImageFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_IMAGE;
} else if (ArchosMediaFile.isPlayListFileType(mMft.fileType)) {
mediaType = FileColumns.MEDIA_TYPE_PLAYLIST;
}
}
}
mMimeType = mimeType;
mMediaType = mediaType;
mRetrieve = retrieve;
}
示例10: getPath
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private static String getPath(Context context, Uri uri) {
String path = null;
String[] projection = {FileColumns.DATA};
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor == null) path = uri.getPath();
else {
cursor.moveToFirst();
int column_index = cursor.getColumnIndexOrThrow(projection[0]);
path = cursor.getString(column_index);
cursor.close();
}
return path == null || path.isEmpty() ? uri.getPath() : path;
}
示例11: buildDocSelection
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private String buildDocSelection() {
StringBuilder selection = new StringBuilder();
Iterator<String> iter = PreparedResource.sDocMimeTypesSet.iterator();
while (iter.hasNext()) {
/*
* selection.append("(" + FileColumns.MIME_TYPE + "=='" +
* iter.next() + "') OR ");
*/
selection.append("(" + FileColumns.DATA + " LIKE '" + iter.next()
+ "') OR ");
}
Log.e("hejie", selection.toString());
return selection.substring(0, selection.lastIndexOf(")") + 1);
}
示例12: getItemMimetype
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private String getItemMimetype(Object item) {
int type = mDelegate.getItemMediaType(item);
if (type == FileColumns.MEDIA_TYPE_IMAGE) {
return GalleryUtils.MIME_TYPE_IMAGE;
} else if (type == FileColumns.MEDIA_TYPE_VIDEO) {
return GalleryUtils.MIME_TYPE_VIDEO;
} else {
return GalleryUtils.MIME_TYPE_ALL;
}
}
示例13: loadInBackground
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
// TODO: This probably doesn't work
mMediaSet.reload();
final MatrixCursor cursor = new MatrixCursor(PhotoSetLoader.PROJECTION);
final Object[] row = new Object[PhotoSetLoader.PROJECTION.length];
final SparseArray<MediaItem> mediaItems = new SparseArray<MediaItem>();
mMediaSet.enumerateTotalMediaItems(new ItemConsumer() {
@Override
public void consume(int index, MediaItem item) {
row[PhotoSetLoader.INDEX_ID] = index;
row[PhotoSetLoader.INDEX_DATA] = item.getContentUri().toString();
row[PhotoSetLoader.INDEX_DATE_ADDED] = item.getDateInMs();
row[PhotoSetLoader.INDEX_HEIGHT] = item.getHeight();
row[PhotoSetLoader.INDEX_WIDTH] = item.getWidth();
row[PhotoSetLoader.INDEX_WIDTH] = item.getWidth();
int rawMediaType = item.getMediaType();
int mappedMediaType = FileColumns.MEDIA_TYPE_NONE;
if (rawMediaType == MediaItem.MEDIA_TYPE_IMAGE) {
mappedMediaType = FileColumns.MEDIA_TYPE_IMAGE;
} else if (rawMediaType == MediaItem.MEDIA_TYPE_VIDEO) {
mappedMediaType = FileColumns.MEDIA_TYPE_VIDEO;
}
row[PhotoSetLoader.INDEX_MEDIA_TYPE] = mappedMediaType;
row[PhotoSetLoader.INDEX_SUPPORTED_OPERATIONS] =
item.getSupportedOperations();
cursor.addRow(row);
mediaItems.append(index, item);
}
});
synchronized (mMediaSet) {
mMediaItems = mediaItems;
}
return cursor;
}
示例14: loadBucketEntriesFromFilesTable
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private static BucketEntry[] loadBucketEntriesFromFilesTable(
JobContext jc, ContentResolver resolver, int type) {
Uri uri = getFilesContentUri();
Cursor cursor = resolver.query(uri,
PROJECTION_BUCKET, BUCKET_GROUP_BY,
null, BUCKET_ORDER_BY);
if (cursor == null) {
Log.w(TAG, "cannot open local database: " + uri);
return new BucketEntry[0];
}
ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
int typeBits = 0;
if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_IMAGE);
}
if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_VIDEO);
}
try {
while (cursor.moveToNext()) {
if ((typeBits & (1 << cursor.getInt(INDEX_MEDIA_TYPE))) != 0) {
BucketEntry entry = new BucketEntry(
cursor.getInt(INDEX_BUCKET_ID),
cursor.getString(INDEX_BUCKET_NAME));
if (!buffer.contains(entry)) {
buffer.add(entry);
}
}
if (jc.isCancelled()) return null;
}
} finally {
Utils.closeSilently(cursor);
}
return buffer.toArray(new BucketEntry[buffer.size()]);
}
示例15: loadBucketEntries
import android.provider.MediaStore.Files.FileColumns; //导入依赖的package包/类
private BucketEntry[] loadBucketEntries(JobContext jc) {
Uri uri = mBaseUri;
Log.v("DebugLoadingTime", "start quering media provider");
Cursor cursor = mApplication.getContentResolver().query(uri,
PROJECTION_BUCKET, BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);
if (cursor == null) {
Log.w(TAG, "cannot open local database: " + uri);
return new BucketEntry[0];
}
ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
int typeBits = 0;
if ((mType & MEDIA_TYPE_IMAGE) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_IMAGE);
}
if ((mType & MEDIA_TYPE_VIDEO) != 0) {
typeBits |= (1 << FileColumns.MEDIA_TYPE_VIDEO);
}
try {
while (cursor.moveToNext()) {
if ((typeBits & (1 << cursor.getInt(INDEX_MEDIA_TYPE))) != 0) {
BucketEntry entry = new BucketEntry(
cursor.getInt(INDEX_BUCKET_ID),
cursor.getString(INDEX_BUCKET_NAME));
if (!buffer.contains(entry)) {
buffer.add(entry);
}
}
if (jc.isCancelled())
return null;
}
Log.v("DebugLoadingTime", "got " + buffer.size() + " buckets");
} finally {
cursor.close();
}
return buffer.toArray(new BucketEntry[buffer.size()]);
}