0

i have saved drawable images in internal storage by compressing them in bitmap format. the problem is that i want to retrieve those image files and wants to display them in grid view i am able to list the total no of files but i am not able to display those files in image view. here is my code

        Intent i = getIntent();
        int position = i.getExtras().getInt("id");
        ImageAdapter imageAdapter = new ImageAdapter(this);

        ImageView imageView = (ImageView) findViewById(R.id.SingleView); 
        ContextWrapper cw = new ContextWrapper(getApplicationContext());
           File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
           File[] imageList = directory.listFiles();
           if(imageList == null){
               imageList = new File[0];
                }
           Log.i("My","ImageList Size = "+imageList.length);


        imageView.setImageResource(imageAdapter.  (....?) );
Sidra Arshad
  • 11
  • 1
  • 3
  • if you have the file path convert it to URI `Uri.fromFile(new File("/sdcard/cats.jpg"))` – Murtaza Khursheed Hussain Jan 27 '15 at 10:42
  • for storing better use `Environment.getExternalStorageDirectory().getAbsolutePath()`, more about [HERE](http://stackoverflow.com/questions/5453708/android-how-to-use-environment-getexternalstoragedirectory) – snachmsm Jan 27 '15 at 10:56

1 Answers1

0

set Image(From Sd card) to imageview get the path of the image which is in sdcard. and you can assign it by creating Bitmap

String filePath = Environment.getExternalStorageDirectory()
                .getAbsolutePath() + File.separator + "your_image_name.png";
        Bitmap bmp = BitmapFactory.decodeFile(filePath);
        imageView.setImageBitmap(bmp);

Another way to set imageview you can also use third party library also which may have resize and Scaling options too. like ImageLoader

user1140237
  • 5,015
  • 1
  • 28
  • 56
  • i don't want to store them in external memory .. i want to retrieve them for internal memory i:e data/data/com.example.myproject/img_Dir for example i have 5 images in this folder i want to display these images in gridview – Sidra Arshad Jan 28 '15 at 13:57
  • @SidraArshad same way you can follow if you have image folder path. i mean whole path of the image – user1140237 Jan 28 '15 at 13:59