如何读取图库中所有图像的名称?

How do I read the names of all the images in the gallery?

我阅读了这些链接: https://docs.microsoft.com/en-us/xamarin/android/platform/content-providers/contacts-contentprovider 但我想读取图库中所有图像的名称并将它们保存在组合框中。

您可以直接访问 ContentResolver 以获得针对 ContentProvider 的光标。

List<string> imageNames = new List<string>();
var imagecursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, null, null,null, null);
//imagecursor.MoveToFirst();
if (imagecursor == null || imagecursor.Count <= 0) return;
while (imagecursor.MoveToNext())
    {
       string name = imagecursor.GetString(imagecursor.GetColumnIndex(MediaStore.Images.ImageColumns.Title));
       imageNames.Add(name);
    }
imagecursor.Close();

别忘了请求 READ_EXTERNAL_STORAGE 许可。