Select image (logo) from gallery, save image, open selected image on program load for future use

34 Views Asked by At

First program in Android Studio with java and i'm struggling on one piece, any guidance would really be appreciated. Simply would like the user to have the capability of selecting their image(logo) for use in the app. The image selection will be saved and will open and loaded into the image view again upon reopening the app.

Currently the user pushes a button that opens the gallery for image selection. When the user picks the image it is displayed in the image view. That portion is working fine. I tried to save the Uri as a string into SharedPreferences and then load the image back into the image view when the program starts again. This is where i'm hung up. It says I don't have permission to open. I'm not sure if this is the best approach. Should I save the image into a folder in my application and then i don't have to worry about permission issues or am i missing something easy loading it back from the gallery? I seemed to have tried this 1000 different ways and always get stuck.

Below sample code is one of many tries to load the image from the gallery back into the image view when the program opens.

    ImageView imageView = findViewById(R.id.UserLogo);
    logocompany = SettingsHelper.getLOGO(this);
    imageView.setImageURI(Uri.parse(logocompany));
0

There are 0 best solutions below