Forum Xamarin Xamarin.Android

How to open any type of File from Internal Storage of android Device

AmolJainAmolJain INMember ✭✭

Hi

i want to open a file (,pdf,video etc) from internal storage of android device. but it throw me an error like (Permission denied).

My file is also exist in internal storage path,

and i have sets following permissions also

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_OWNER_DATA" />

i attached error image please check it
its showing error message as ==> file not found (/data/data/androdapp.androidapp/
app_contentsuploadfiles/document.docx :open failed :
Access (Permission denied)).

here is my code to read file from internal location

var file = new Java.IO.File(path);
try
{
String mimeType = CommonFunctions.GetMimeType(path);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(Android.Net.Uri.FromFile(file), mimeType);
myContext.StartActivity(intent);
}
catch (ActivityNotFoundException e)
{
throw;
}

not getting whats the issue to read file

please reply

Thanks

Answers

Sign In or Register to comment.