简体   繁体   中英

One Column to Array SQLite

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 ????

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM