1. Are you ready for the Galaxy S20? Here is everything we know so far!

get image path

Discussion in 'Android Development' started by danielpalfrey, Feb 15, 2016.

  1. danielpalfrey

    danielpalfrey Lurker
    Thread Starter

    Hi there, I am looking for a way to get the path of an image in ImageView and then save the to shared preferences. First time with me needing to save an app to restore its state on restart.

    Thanks for any advice

    Dan
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

  3. danielpalfrey

    danielpalfrey Lurker
    Thread Starter

    I was told that this would be easy to impliment. The image is selected from presets within the app, The image path in this case is R.drawable.arrow
    but if the user selects a different image this changes, how would I retrieve that info or is it the same as above?
     
  4. danielpalfrey

    danielpalfrey Lurker
    Thread Starter

    Or is there a better alternative than this? I just thought passing the path would be easier on the program than passing around a picture :/ If that can be done
     
  5. danielpalfrey

    danielpalfrey Lurker
    Thread Starter

    Ok, this can be done. I have managed to do it.
    In my case the picture was predefined in the app so I called call the image directly in this case. it just means writing new code for every combination of choices which will be a pain rather than like .net where you can write a variable code allowing multiple results.

    But this is the best solution I could come up with, was when the user sets the predefined image an intent is used to pass this info on as boolean which the calls for the image path and at this point I save the path as int and call for it later on form load under the setImageBackgound
     
  6. danielpalfrey

    danielpalfrey Lurker
    Thread Starter

    I am tidieing up the code and adding comment. Once this is done I will post the code so you can see my solution
     
Loading...

Share This Page

Loading...