0

can someone tell me how to change a column to an array ???

Im Making a Database and want view one of my column in android.

I have 6 column, but i just want one column from them to be an array for my listview.

Here is my table :

static final String KEY_ROWID = "_id";
static final String KEY_A = "a";
static final String KEY_B = "b";
static final String KEY_C = "c";
static final String KEY_D = "d";
static final String KEY_E = "e";

My goal is to make the "a" column to an array like this :

String arraylist[] = { "a" column data };

how can i get that ????

2
  • 1
    Query usually returns a Cursor. If you use a CursorAdapter (like SimpleCursorAdapter, or even your own subclass of it), you don't have to convert to an array/list. Would that work for you for this problem? Commented Jul 25, 2013 at 5:08
  • I dont know, but thanks for your advice. I'll try (^^)b Commented Jul 25, 2013 at 5:50

1 Answer 1

1

It sounds like you should be using the cursor adapter, but if you have a good reason to use the array here's the gist of how I'd do it.

String arraylistA[];
...
yourCursor.moveToNext();
i = 0;

...
arraylistA[i] = { (yourCursor.getString(yourCursor.getColumnIndex(YourDBHelper.yourcolumnnameA))};
i + 1;
                                            or
arraylistA[i] = { (yourCursor.getString(yourCursor.getColumnIndex("yourcolumnnameA"))};
i + 1;

And then you loop thru the moveToNext and the valuation of the arraylistA. You will obviously have to define your other lists and a better loop.

Sign up to request clarification or add additional context in comments.

1 Comment

Hope it work for you, if you have more issues please contact me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.