Ejemplo n.º 1
0
        public static string GetRealPathFromURI(Android.Net.Uri contentUri)
        {
            var mediaStoreImagesMediaData = "_data";

            string[] projection             = { mediaStoreImagesMediaData };
            Android.Database.ICursor cursor = Application.Context.ContentResolver.Query(contentUri, projection, null, null, null);
            int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData);

            cursor.MoveToFirst();
            return(cursor.GetString(columnIndex));

            //ContentResolver cr = Application.Context.ContentResolver;

            //Android.Net.Uri uri = MediaStore.Files.GetContentUri("external");

            //// every column, although that is huge waste, you probably need
            //// BaseColumns.DATA (the path) only.
            //String[] projection = null;

            //// exclude media files, they would be here also.
            //String selection = MediaStore.Files.FileColumns.MediaType + "="
            //        + Android.po;
            //String[] selectionArgs = null; // there is no ? in selection so null here

            //String sortOrder = null; // unordered
            //Cursor allNonMediaFiles = cr.query(uri, projection, selection, selectionArgs, sortOrder);
        }
Ejemplo n.º 2
0
        public String getRealPathFromURI(Android.Net.Uri contentUri)
        {
            var mediaStoreImagesMediaData = "_data";

            string[] projection             = { mediaStoreImagesMediaData };
            Android.Database.ICursor cursor = this.ContentResolver.Query(contentUri, projection,
                                                                         null, null, null);
            int columnIndex = cursor.GetColumnIndexOrThrow(mediaStoreImagesMediaData);

            cursor.MoveToFirst();
            return(cursor.GetString(columnIndex));
        }