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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:58:56+00:00 2026-06-12T00:58:56+00:00

i am reading the string of MediaStore.Images.Media.DATA from an ArrayList into an array so

  • 0

i am reading the string of MediaStore.Images.Media.DATA from an ArrayList into an array so i can use the images from my SD card instead of the images in the R.drawable folder for a coverflow gallery app. and have run into a brick wall. with the problem of reading integer type vs. string type for image information.

was able to get the URIs from all the images from the SD card into the arraylist and don’t know what is the next step to take.

is it worth continuing with this approach or is it better to abandon this and try another way to accomplish the task of changing the source of images for this coverflow app from the R.drawables folder to the SD card.

here is what i did

first, here is the way it gets the images from the R.drawable folder in android using an array as part of the process:

      public class ImageAdapter extends BaseAdapter {
       int mGalleryItemBackground;
       private Context mContext;

       private FileInputStream fis;

      // private Integer[] mImageIds = {
       //       R.drawable.pic01,
         //      R.drawable.pic02,
            //    R.drawable.pic03,
            //  R.drawable.pic04,
           //   R.drawable.pic05,
           //   R.drawable.pic06,
          //   R.drawable.pic07,
         //     R.drawable.pic08,
        //    R.drawable.pic09
       //   };

       private ImageView[] mImages;

my idea was to use a cursor to read the URIs like this “//mnt/sdcard/pic01.png” from the SD card and use these addresses instead of the ones in the array from the R.drawables like this “R.drawable.pic02” in the array.

this is what i did and this part worked with no problems:
i got all the URIs from the images on the SD card and stored them in an arrayList, so far everything works great. i verified that it works perfectly by using a Toast to show the loaded URIs on the activity screen.

       ArrayList<String> list1 = new ArrayList<String>();

    String[] proj = {MediaStore.Images.Media.DATA};
    Cursor cur = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj, null, null, null);
    if (cur.getCount() > 0) {
        while (cur.moveToNext()) {
            String pic = cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DATA));
            list1.add(pic);
        //    Toast.makeText(CoverFlowExample.this, "data name: " + pic, Toast.LENGTH_SHORT).show();
         //   Log.d("TAG", "ID: " + pic);
        }
       }
    cur.close();

next i tried to read these strings into the array used for the R.drawables array and this is where i got into trouble: the program uses Integer as the type for the array. so i guess this array is the wrong place to read URIs into. then if this is the wrong place. what to do now?

         Integer[] mImageIds = new Integer[list1.size()];

    for(int t = 0; t<= list1.size(); t++){
        mImageIds[t]= list1.get(t); // type mismatch cannot convert string to integer
    }

    Toast.makeText(CoverFlowExample.this, "data name: " + y , Toast.LENGTH_SHORT).show();

the error i am getting is “type mismatch, cannot convert string to integer” for this part:

      mImageIds[t]= list1.get(t);

here is the rest of the code from the getview part of the app: i am now trying to figure out what to do next.

           public View getView(int position, View convertView, ViewGroup parent) {

        //Use this code if you want to load from resources from external source
        ImageView i = new ImageView(mContext);

            // this method is what someone suggested to use but i don't know how to use this, what do i put for "image" and how to read URIs from arrayList to this?
        i.setImageBitmap(BitmapFactory.decodeFile("image_" + position));

            // this works for reading in only one image from the SD card into the coverflow app
        i.setImageBitmap(BitmapFactory.decodeFile("/mnt/sdcard/pic04.png"));

   // when getting from R.drawable images -->  i.setImageResource(mImageIds[position]);

        i.setLayoutParams(new CoverFlow.LayoutParams(130, 130));
        i.setScaleType(ImageView.ScaleType.MATRIX);         
        return i;

        //return mImages[position];
    }
  • 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-06-12T00:58:57+00:00Added an answer on June 12, 2026 at 12:58 am

    As you have the URIs / file system path already, you can use one of the createFrom* methods of Drawable java doc in android docu to have it loaded.

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

Sidebar

Related Questions

I am reading in from a text file using StreamReader into a string array
ok..so i'm reading from an sqlite db data into a string...it works..but when the
I am reading the string of data from the oracle database that may or
I am reading string data from a PLIST which I am using to create
If I'm reading a string from a config file, I'd use a similar approach
I wrote a template function for reading in string or numerical data from files
Hey. I am reading in a string from a file and attempting to use
Hi there I'm reading a string and breaking each word and sorting it into
I was reading How can I get query string values in JavaScript? on Stackoverflow
How does performance for reading/adding values from/to Dictionary(Of String, SomeReferenceType) depend on the number

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.