0

The following code is what I plan to do.

Integer[] imageId = {
    R.drawable.a
    R.drawable.b
    R.drawable.c
    R.drawable.d
};

I can store these images into a Integer array but what if I plan to store URL picture that download from internet into Integer Array. Is that a way to do this? Thank you

3
  • why will you use Integer[] to store URL . Use String array . Commented Jul 10, 2016 at 6:05
  • What are you trying to do? can you provide more information...? Commented Jul 10, 2016 at 6:09
  • Those Integers are representation of those resource image found in the res folder relative to R file. The image path is a string so you want to have an array of Strings rather. Commented Jul 10, 2016 at 6:32

2 Answers 2

3

If you want to store a Url picture (which usually is a string) in an int array you have to parse that string (url of the picture) into an int:

Integer[] imageUrlsAndIds = {
    Integer.parseInt("some Url"),
    Integer.parseInt("an Url of a picture of a pretty girl"),
    Integer.parseInt("another Url from Internet"),
    R.drawable.a,
    R.drawable.b,
    R.drawable.c,
    R.drawable.d
}
Sign up to request clarification or add additional context in comments.

Comments

0

No, that's not a correct way. Storing resource id of images(which is Integer) is totally different from storing image path (which is String). You can use, String array to store url path of images.

Example :

String[] imageID = { "http://www.somewhere.com/data/drugaddiction/logo.png", "http://www.somewhere.com/data/drugaddiction/image.png" };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.