Java Android ArrayList-相同的数字

Java Android ArrayList-相同的数字,java,android,arraylist,Java,Android,Arraylist,我这里有点小问题。 我正在从数据库中检索列并将它们保存在ArrayList中 public ArrayList<String> getColumn(String table, String column) { ArrayList<String> columns = new ArrayList<String>(); Cursor result = db.query(true, table, new String[] {

我这里有点小问题。
我正在从数据库中检索列并将它们保存在ArrayList中

public ArrayList<String> getColumn(String table, String column) {

    ArrayList<String> columns = new ArrayList<String>();
    Cursor result = db.query(true, table,
            new String[] { column }, null, null, null, null,
            null, null);

    if (result.moveToFirst()) {
        do {
            columns.add(result.getString(result
                    .getColumnIndex(column)));
        } while (result.moveToNext());
    } else {
        return null;
    }
    return columns;
}
但它应该是:

[2, 3, 6]
[2, 4, 8]
[456, 45645, 6544]
[1, 2, 2]
[2, 2, 2]
[1.12.2015, 31.11.2016, 29.10.2014]
[0, 0, 0]
如您所见,如果数字匹配,它只会将其添加到ArrayList中。 我有没有办法阻止它这样做

编辑: 为了更好的解释

数据库:

下面是我如何检索和显示数组:

ArrayList<String> a, ac, b, c, d, e, f;

        a = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_MARKE);
        ac = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_MODELL);
        b = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_FAHRZEUGPREIS);
        c = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_FAHRZEUGTYP);
        d = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_GETRIEBE);
        e = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_ERSTZULASSUNG);
        f = myDb.getColumn(DATABASE_TABLE, DBSuche.VAR_PKW_COUNTER);

        int i = 0;

        for ( ; i <= a.size() - 1; i++) {
            Log.e(TAG, String.valueOf(a));
            Log.e(TAG, String.valueOf(ac));
            Log.e(TAG, String.valueOf(b));
            Log.e(TAG, String.valueOf(c));
            Log.e(TAG, String.valueOf(d));
            Log.e(TAG, String.valueOf(e));
            Log.e(TAG, String.valueOf(f));
            Log.e(TAG, i + " | " + a.size());
            Log.e("---------------", "----------");
        }
数组列表a、ac、b、c、d、e、f;
a=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u标记);
ac=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u model);
b=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u FAHRZEUGPREIS);
c=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u FAHRZEUGTYP);
d=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u GETRIEBE);
e=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u ERSTZULASSUNG);
f=myDb.getColumn(数据库表,DBSuche.VAR\u PKW\u计数器);
int i=0;

对于(;i请尝试将查询中的
布尔值更改为
false

从android开发者网站:

Cursor query (boolean distinct, 
                String table, 
                String[] columns, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String orderBy, 
                String limit, 
                CancellationSignal cancellationSignal)
distinct boolean:如果希望每一行都是唯一的,则为true,否则为false


阅读此

这很奇怪,首先,您有一个字符串数组,因此显示的输出不匹配。您可能在某处使用了一些
Set
。如果您打印result.getString(result.getColumnIndex(column)),请发布一个,它显示了正确的值?发布查询尝试将
查询中的
布尔值更改为
在检查arraylist中添加的元素之前,请检查查询返回的内容
Cursor query (boolean distinct, 
                String table, 
                String[] columns, 
                String selection, 
                String[] selectionArgs, 
                String groupBy, 
                String having, 
                String orderBy, 
                String limit, 
                CancellationSignal cancellationSignal)