简体   繁体   English

一列数组SQLite

[英]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. 我正在制作数据库,并希望在android中查看我的专栏之一。

I have 6 column, but i just want one column from them to be an array for my listview. 我有6列,但我只希望它们中的一列成为我的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 : 我的目标是使“ a”列成为这样的数组:

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. 然后循环通过moveToNext和arraylistA的赋值。 You will obviously have to define your other lists and a better loop. 显然,您将必须定义其他列表和更好的循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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