0

I have saved my gif on Sharedpreference like this

 protected void onActivityResult(int requestcode, int resultcode,
                                Intent imagereturnintent) {
    super.onActivityResult(requestcode, resultcode, imagereturnintent);
    switch (requestcode) {
        case select_photo:
            if (resultcode == RESULT_OK) {


                    Uri imageuri = imagereturnintent.getData();
                    uriPath.setText("URI Path: " + imageuri.toString());


                SharedPreferences.Editor editor = sharedpreferences.edit();
                editor.putString(Name, imageuri.toString());

                editor.apply();

                Glide.with(getApplicationContext()).load(Uri.parse(imageuri.toString())).into(gallery_image);


            }
            }

and then I reload Glide in oncreate like this

 sharedpreferences = getSharedPreferences(mypreference,
            Context.MODE_PRIVATE);

   if (sharedpreferences.contains(Name)) {
    String Agi= sharedpreferences.getString(Name, "");
    Glide.with(getApplicationContext()).load(Uri.parse(Agi)).into(gallery_image);


    }

Glide works fine when I exit and return to the app, but as soon as I kill the app(because users may do that to boost their phone),the gif will not show anymore. The strange thing is that with a normal image.jpg works fine even after app kill.

FringoDev
  • 7
  • 5

1 Answers1

-1

I found the solution at Martin Singers answer in another question at this link:How to save Image in shared preference in Android | Shared preference issue in Android with Image. I needed to get persistableUriPermission into my code.Android studio is way better than Eclipse but now developers don't help each other anymore.

FringoDev
  • 7
  • 5