我有这段代码,可以让我阅读手机图库的内容并随机滚动其内容。
public static Uri getRandomImage(ContentResolver resolver) {
String[] projection = new String[] {
BaseColumns._ID
};
Random rand = new Random();
int p = 2 + rand.nextInt(8-2+1);
Uri uri = p == 0 ? Media.EXTERNAL_CONTENT_URI : Media.EXTERNAL_CONTENT_URI;
Cursor cursor = Media.query(resolver, uri, projection, null, MediaColumns._ID);
if (cursor == null || cursor.getCount() <= 0) {
return null;
}
cursor.moveToPosition(new Random().nextInt(cursor.getCount()));
return Uri.withAppendedPath(uri, cursor.getString(0));
}
但我想修改此代码以读取我设置的文件夹的内容。我怎样才能做到这一点?
非常感谢您