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 6351431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:00:22+00:00 2026-05-24T22:00:22+00:00

What does this method accomplish? URL aURL = new URL(myRemoteImages[position]); myRemoteImages is a String

  • 0

What does this method accomplish?

 URL aURL = new URL(myRemoteImages[position]);

myRemoteImages is a String list, with 4 different variables. And position is a

int position;

EDIT:
So if there anyway i could take the place of position with possibly something else?

possibly

 myRemoteImages{1,2,3,4};?

EDIT: i am using this to get the the URI for each image in the cahce…

public void getImagesfromCache(){
        ImageAdapter adapter = new ImageAdapter();

    String[] cachImages = myRemoteImages;

    try {   
     URL aURL2 = null;
     aURL2 = new URL(cachImages[position]);
     URI imageCacheUri = null;


     try {
            imageCacheUri = aURL2.toURI();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        if(new File(new File(this.getApplicationContext().getCacheDir(), "thumbnails"),"" + imageCacheUri.hashCode()).exists()){
            Log.v("FOUND", "Images found in cache! Now being loaded!");
            String cacheFile = this.getApplicationContext().getCacheDir() +"/thumbnails/"+ imageCacheUri.hashCode();
            ImageView i = new ImageView(this.getApplicationContext());
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(cacheFile);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            Bitmap bm = BitmapFactory.decodeStream(fis);

             i.setImageBitmap(bm);
             putBitmapInDiskCache(imageCacheUri, bm);

             Log.v("Loader", "Image saved to cache");

             ((Gallery) findViewById(R.id.gallery))
              .setAdapter(new ImageAdapter(MainMenu.this));
        }

    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

As you see where position is used, how could i go about another way to return the URL’s to get the images in the cache?

Could i possibly store each URI in a SharePreference and fetch them in onCreate()??

  • 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-24T22:00:23+00:00Added an answer on May 24, 2026 at 10:00 pm

    It creates a URL object, from the url string specified by the element within the array (myRemoteImages) at the specific position.

    The following syntax creates a URL object

    URL aURL = new URL(<a string describing a URL>);
    

    The following syntax gets the String value at the specified position

    myRemoteImages[position]
    

    So, to get a URL for each position, you could do

    URL url1 = new URL(myRemoteImages[0]);
    URL url2 = new URL(myRemoteImages[1]);
    URL url3 = new URL(myRemoteImages[2]);
    URL url4 = new URL(myRemoteImages[3]);
    

    It would be far better though to have an array of URLs though. So it would be

    URL [] urls = new URL[myRemoteImages.length];
    for (int i = 0; i < myRemoteImages.length; i++) {
       urls[i] = myRemoteImages[i];
    }
    

    With this array of URLs, even though you know there are only 4 images, it can be extended easily without having to change any code. Hard coding is VERY bad, and will usually lead to errors in the long run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the method System.Windows.Forms.Control.Invoke(Delegate method) Why does this give a compile time error: string
Can you tell me what does this method return type is: List<passenger> recommend(Car a,
Does anyone have any thoughts on this method? I have did some performance testing
I use the Action<object>.BeginInvoke() method, does this use the thread pool or not? I
I got this question from this discussion . A method call like object.m does
Why does this lambda expression not compile? Action a = () => throw new
Does this pattern: setTimeout(function(){ // do stuff }, 0); Actually return control to the
Why does this javascript return 108 instead of 2008? it gets the day and
What does this mean exactly? I'm doing something like this: File.Copy(@\\foo\bar\baz.txt, @c:\test\baz.txt); MSDN doesn't
What does this option do? It is accessible from the Build menu.

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.