Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:45:07+00:00 2026-05-24T23:45:07+00:00

URI imageUri = null; //Setting the Uri of aURL to imageUri. try { imageUri

  • 0
URI imageUri = null;

//Setting the Uri of aURL to imageUri.
try {
    imageUri = aURL.toURI();
} catch (URISyntaxException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

I am using this code to translate a URL to a URI. How could I save the imageUri to a SharedPreferences, or a memory where it wouldnt be deleted onDestroy()?

I dont want to do SQLite database because the URI will change when the URL’s change.I dont want to use up memory for unused URI’s

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:45:07+00:00Added an answer on May 24, 2026 at 11:45 pm

    To get started using SharedPreferences for storage you’ll need to have something like this in your onCreate():

    SharedPreferences myPrefs = getSharedPreferences(myTag, 0);
    SharedPreferences.Editor myPrefsEdit = myPrefs.edit();
    

    I think you can do something like this to store it:

    myPrefsEdit.putString("url", imageUri.toString());
    myPrefsEdit.commit();
    

    And then something like this to retrieve:

    try {
        imageUri = URI.create(myPrefs.getString("url", "defaultString"));
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an Uri returned from image gallery to create a Bitmap. I have
I created a cache for my images here public void putBitmapInDiskCache(URI imageUri, Bitmap avatar)
confused - given a track uri, I can get one album but possibly more
I have an URI image file, and I want to reduce its size to
ResourceContext.matchResource(URI) allows me to convert a URI to a Resource, but how do I
I have a Uri object being passed to a constructor of my class. I
I have a System.Uri, e.g., var uri = new Uri(http://www.domain.com/foo/bar); How do I get
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?
When the document(uri) function is used to load another document within the XSLT, where
Given a pack:// URI, what's the best way to tell whether a compiled resource

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.