Help!!!! Having problems with displaying pictures from SDCard
<p>everyone. I am having some serious problems with displaying pictures from the SDCard in a GridView. I am using Motodev Studio for android 1.3. Here is my code:</p>

<pre><code>    package com.newtestforsdcarddisplay;

    import android.app.Activity;
    import android.os.Bundle;
    import android.content.Context;
    import android.database.Cursor;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.GridView;
    import android.widget.AdapterView;
    import android.widget.ImageView;
    import android.widget.Toast;
    import android.provider.MediaStore;
    import android.provider.MediaStore.Images.Thumbnails;
    import android.net.Uri;

    public class MainActivity extends Activity {

        public Cursor myImageCursor;
        public int columnNumber;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

    String[] imageIDs = new String[]{MediaStore.Images.Thumbnails.IMAGE_ID};

    Uri myImagesSource = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;

    myImageCursor = managedQuery(myImagesSource, 
                    imageIDs, null, null, null);

             columnNumber = myImageCursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);

            GridView PhoneImageView = (GridView)findViewById(R.id.sdcard);
            PhoneImageView.setAdapter(new ImageAdapter(this));

            PhoneImageView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                 public void onItemClick(AdapterView&lt;?&gt; parent, View v,
        int position, long id) {

       String[] data = { MediaStore.Images.Media.DATA };
       Cursor  viewImageCursor = managedQuery(
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, data,
        null, null, MediaStore.Images.Thumbnails._ID );
                   int imageColumnIndex = viewImageCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
               viewImageCursor.moveToPosition(position);
               viewImageCursor.moveToFirst();
               String filepath = viewImageCursor.getString(imageColumnIndex);
               Toast.makeText(MainActivity.this, filepath, Toast.LENGTH_LONG).show();

               Bitmap yourSelectedImage = BitmapFactory.decodeFile(filepath);

                 }
           });
        }       
    }



package com.newtestforsdcarddisplay;

import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.net.Uri;
import android.provider.MediaStore;

public class ImageAdapter extends BaseAdapter{

    final   MainActivity pca = new MainActivity();
    private Context context;

    public ImageAdapter(Context localContext) {
       context = localContext;
    }

    public int getCount() {
        return pca.myImageCursor.getCount();

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

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView picturesView;
        if (convertView == null) {
            picturesView = new ImageView(context);
            // Move cursor to current position
            pca.myImageCursor.moveToPosition(position);
            // Get the current value for the requested column
            Cursor c = pca.myImageCursor;
            int imageID = c.getInt(pca.columnNumber);
            // Set the content of the image based on the provided URI
            picturesView.setImageURI(Uri.withAppendedPath(
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + imageID));
            picturesView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            picturesView.setPadding(8, 8, 8, 8);
            picturesView.setLayoutParams(new GridView.LayoutParams(100, 100));
        }
        else {
            picturesView = (ImageView)convertView;
        }
        return picturesView;
    }   
}
</code></pre>

<p>Can somebody help me please??? All I am getting is a blank screen. Any help would be much appreciated:) :)</p>
