Try to search your question here, if you can't find : Ask Any Question Now ?

how to fix android.os.FileUriExposedException <filepath > exposed beyond app through Intent.getData()

HomeCategory: stackoverflowhow to fix android.os.FileUriExposedException <filepath > exposed beyond app through Intent.getData()
Avatarcraig asked 2 weeks ago

I am trying to open a pptx file which is already stored in-app data directory but I am facing an error to open the ppt file.

I have used the basic method to get the file path and then the Uri , from there passing the file Uri to the intent to open the pptx file.

I have also tried that FileProvider, But doesn’t seem working out!

***I am using Recycle view which has card view each has a button to open a specific file , hence I am using an Adapter,viewholder….and the below onclick method is available under the adapter class–>onBindViewHolder function.

///this is onClick function used to open the specific file stored

@Override
public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {

    holder.fOpen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            File root=new File(holder.mname.getContext().getFilesDir(),DIRECTORY_DOWNLOADS);
            File file=new File(root.getPath(),"Introduction.pptx");
            Intent intent=new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(file),"application/pptx");
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            holder.mname.getContext().startActivity(intent);
        }
    });
}

}
///

The error message I am getting is :
//
android.os.FileUriExposedException: file:///data/user/0/com.example.r_source/files/Download/Introduction.pptx exposed beyond app through Intent.getData()
//

1 Answers
Best Answer
AvatarMannu answered 2 weeks ago
Your Answer

0 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com