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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:44:38+00:00 2026-06-16T01:44:38+00:00

I am doing an application which consists of a cover flow. Currently I am

  • 0

I am doing an application which consists of a cover flow.
Currently I am trying to make the cover flow images be obtained from the sd card.
But I am not exactly sure how should I display the image.

this is the image adapter:

    public class ImageAdapter extends BaseAdapter {

     int mGalleryItemBackground;
     private Context mContext;

     private FileInputStream fis;
     private Integer[] mImageIds = {

       //Instead of using r.drawable, 
         i need to load the images from my sd card instead

             R.drawable.futsing,
             R.drawable.futsing2

     };

     private ImageView[] mImages;

     public ImageAdapter(Context c) {
      mContext = c;
      mImages = new ImageView[mImageIds.length];
     }

     public int getCount() {
         return mImageIds.length;
     }

     public Object getItem(int position) {
         return position;
     }

     public long getItemId(int position) {
         return position;
     }


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

         int screenSize = getResources().getConfiguration().screenLayout &
         Configuration.SCREENLAYOUT_SIZE_MASK;

         ImageView i = new ImageView(mContext); 
         i.setImageResource(mImageIds[position]);

         switch(screenSize) {
         case Configuration.SCREENLAYOUT_SIZE_XLARGE:
         //Toast.makeText(this, "Small screen",Toast.LENGTH_LONG).show();
         Display display4 = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
         int rotation4 = display4.getRotation();
         Log.d("XLarge:",String.valueOf(rotation4));

         /** LANDSCAPE **/
         if(rotation4 == 0 || rotation4 == 2) 
         {

         i.setLayoutParams(new CoverFlow.LayoutParams(300, 300));
         i.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
         BitmapDrawable drawable = (BitmapDrawable) i.getDrawable();
         drawable.setAntiAlias(true);
         return i;
         }

         /** PORTRAIT **/
         else if (rotation4 == 1 || rotation4 == 3) 
         {
             i.setLayoutParams(new CoverFlow.LayoutParams(650, 650));
             i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
             BitmapDrawable drawable = (BitmapDrawable) i.getDrawable();
             drawable.setAntiAlias(true);
             return i;
         }
         break;

     default:
 }
        return null;

     }
   /** Returns the size (0.0f to 1.0f) of the views 
      * depending on the 'offset' to the center. */ 
      public float getScale(boolean focused, int offset) { 
        /* Formula: 1 / (2 ^ offset) */ 
          return Math.max(0, 1.0f / (float)Math.pow(2, Math.abs(offset))); 
      } 

 }

and this is how i download and save the file. I need to use the image saved and upload it into my coverflow

 // IF METHOD TO DOWNLOAD IMAGE
void downloadFile() {

    new Thread(new Runnable(){  // RUN IN BACKGROUND THREAD TO AVOID FREEZING OF UI
    public void run(){  
            Bitmap bmImg;
            URL myFileUrl = null;
            try {
                //for (int i = 0; i < urlList.size(); i ++)
                //{
                //url = urlList.get(i);
                myFileUrl = new URL("http://static.adzerk.net/Advertisers/d18eea9d28f3490b8dcbfa9e38f8336e.jpg");    // RETRIEVE IMAGE URL
                //}
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            try {
                HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
                conn.setDoInput(true);
                conn.connect();
                InputStream in = conn.getInputStream();
                Log.i("im connected", "Download");
                bmImg = BitmapFactory.decodeStream(in);

                saveFile(bmImg);
            } catch (IOException e) {
                e.printStackTrace();
            }}   
    }).start(); // START THREAD

    }

    // SAVE THE IMAGE AS JPG FILE
private void saveFile(Bitmap bmImg) {
    File filename;
try {
     // GET EXTERNAL STORAGE, SAVE FILE THERE
     File storagePath = new File(Environment.getExternalStorageDirectory(),"Covers");
     storagePath.mkdirs();
    filename = new File(storagePath + "/image.jpg");
    FileOutputStream out = new FileOutputStream(filename);
    bmImg.compress(Bitmap.CompressFormat.JPEG, 90, out);

    out.flush();
    out.close();
    MediaStore.Images.Media.insertImage(getContentResolver(),filename.getAbsolutePath(), filename.getName(),
            filename.getName());

    // ONCE THE DOWNLOAD FINISHES, CLOSE DIALOG
   Toast.makeText(getApplicationContext(), "Image Saved!", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
    e.printStackTrace();
}   

}
  • 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-16T01:44:39+00:00Added an answer on June 16, 2026 at 1:44 am

    for loading images from Sd card to ImageView change your code as:

    put images path in array :

     String strpath=Environment.getExternalStorageDirectory();
         private String[] mImageIds = {
    
                 strpath+"a.jpg",
                 strpath+"b.jpg",
                 strpath+"c.jpg",
                 .....
         };
    

    and for setting in getView to ImageView you will need to create Drawable :

    ImageView i = new ImageView(mContext); 
    i.setImageDrawable(Drawable.createFromPath(mImageIds[position]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing an application which get songs from mediapicker and saving it to
I have a java application which doing some logic... ... But the java application
I am working on a mini-project which consists of doing a client-server chat application.
I have a windows form application which consists of a bunch of controls, but
I've got an MVC 2 application which won't be doing its own authentication, but
i doing the application which can display all the data in listView . But
Introduction I'm currently doing some bug fixes in an application which is in the
im doing an application in which im transfering file through FTP.i succesfully done all
I am doing an application in which I want to get the screen shots
I am doing mail parsing application which required to convert the HTML file to

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.