views:

21

answers:

1

I have a query in my android app that pulls all image paths from a custom table and displays them to a gallery. The problem is with my database I cant seem to get a row of the database to a String[]. I can easily get the results to a listArray but I need the image path in a string or string array. I want to be able to click on an image in the gallery and have it pull up full screen to be able to zoom in on it or delete it etc. This is the basic query i use

public void listimages() {

    SimpleCursorAdapter adapter;

    String[] columns = {"Image", "ImageDate", "_id"};

    query = new TableImages(this);

    queryString = query.getData("images", columns, null, null, null, null, "ImageDate", "DESC");

    int to[] = {R.id._id1, R.id._id2};
    adapter = new SimpleCursorAdapter(this, R.layout.imagelist, queryString, columns, to);

    Gallery g = (Gallery) findViewById(R.id.gallery);
    g.setAdapter(adapter);
    g.setOnItemClickListener(this);

    try {
        query.destroy();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Intent i = new Intent(ViewAllImages.this, ImageViewer.class);
    Bundle b = new Bundle();
    //I want to be able to use this -> b.putString("image_path", Image);
    b.putlong("id", id);
    i.putExtras(b);
    startActivity(i);
}

This passes the ID to my next activity and the next activity queries the DB pulling that one image path. I still have to use a listview to display the image which makes the app crash on the phone due to memory usage (image is too large).

I can compress the image but I need the path as a string and I cant figure out how to do that without creating a custom content provider or adding a textview and using gettext.toString and thats just getto. My head is killing me as it is with all the reading and coding I have done lol. I have searched all over Google and different forums but I am having problems finding an answer.

Is there a way to use the existing query and get a string or a string array as the result?

Thanks.

A: 

I just ended up building a custom content provider. Now I have alot more flexability in my queries.

Opy