Android: Get entire column data

后端 未结 1 1273
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 01:47

Im trying to get the data of an entire column into a string array. My database contains two columns Id and Names. I want to read all the entries of the names column and put it i

相关标签:
1条回答
  • 2021-01-26 02:02
        int total=0;
        Cursor csr=sdb.query("tablename", null, null,null,null,null,null);
        csr.moveToFirst();
        while(!csr.isAfterLast())
        {
            total++;
             csr.moveToNext();
        }
    
        String strarray[] = new String[total];
    
        Cursor csrs=sdb.query("tablename", null, null,null,null,null,null);
        csrs.moveToFirst();
        int aray=0;
        while(!csrs.isAfterLast())
        {
            strarray[aray]=csrs.getString(1);
            aray++;
            csrs.moveToNext();
        }
    
    0 讨论(0)
提交回复
热议问题