Trying to parse Uri from a string but I get the error permission denial: ACTION_OPEN DOCUMENT

In my code I saved the Uri I got after choosing an image from the gallery as a string file and then saved it in a database then I passed the value of the database into a constructor of the class note and it uses the method getAddress now I want to parse the Uri back from the generated string but it keeps giving me the ACTION_OPEN_DOCUMENT error and I need this done before Tuesday.

package com.example.bookreviewapplication;

import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder> {
    private LayoutInflater inflater;
    private List<Note> notes;
    Uri new_image_Uri;

    Adapter(Context context,List<Note> notes){
        this.inflater = LayoutInflater.from(context);
        this.notes = notes;
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = inflater.inflate(R.layout.add_views,viewGroup,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
        String  title    = notes.get(i).getTitle();
        String genre      = notes.get(i).getGenre();
        String review      = notes.get(i).getReview();
        String address      = notes.get(i).getAddress();

        new_image_Uri = Uri.parse(address);

        viewHolder.nTitle.setText(title);
        viewHolder.nGenre.setText(genre);
        viewHolder.nReview.setText(review);
        viewHolder.nImage.setImageURI(new_image_Uri);
    }

    @Override
    public int getItemCount() {
        return notes.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView nTitle,nGenre,nReview;
        ImageView nImage;

        public ViewHolder(@NonNull final View itemView) {
            super(itemView);
            nTitle  = itemView.findViewById(R.id.review_ttl_1);
            nGenre  = itemView.findViewById(R.id.review_gnr_1);
            nReview  = itemView.findViewById(R.id.review_text_1);
            nImage  = itemView.findViewById(R.id.review_book_1);

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent i = new Intent(v.getContext(),ViewReviewActivity.class);
                    i.putExtra("Title",notes.get(getAdapterPosition()).getTitle());
                    Log.i("tag", notes.get(getAdapterPosition()).getTitle());
                    v.getContext().startActivity(i);
                }
            });
        }
    }
}



Read more here: https://stackoverflow.com/questions/66482272/trying-to-parse-uri-from-a-string-but-i-get-the-error-permission-denial-action

Content Attribution

This content was originally published by Unikid500 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: