Get string path from Android.Net.Uri

FaizalSaidaliFaizalSaidali USMember ✭✭✭

Hi Xamarin team,

I'm trying to get string path from Android.Net.Uri using Xamarin Forms.
I follow the solution from this.

var c1 = ContentResolver.Query (uri, null, null, null, null) line break with given error.

Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()' on a null object reference

Thank you

Answers

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @FaizalSaidali,

    var c1 = ContentResolver.Query (uri, null, null, null, null)
    

    It shows that Android.Net.Uri uri is null.

  • FaizalSaidaliFaizalSaidali USMember ✭✭✭

    Thank you YkshLeo,

    Actually uri has value. I'm attached its view

  • MdDeloyarHossainMdDeloyarHossain USMember
    edited June 2016

    You can solve this by extend current class with Activity class which is into Android.App namespace.
    public class Abc: Activity { { var message = Android.Net.Uri.Parse("content://.............."); ICursor cursor = ContentResolver.Query(message, null, null, null, null):smile: }

Sign In or Register to comment.