문제

I am making an SQLite database in Android in which i have to store 40k words in it. I am getting the words from q txt file.

I am storing the words first in a list and then from list to database. But when I store words in table and retrieve from that i get only 20k words. The rowcount of the table is also 20k but i have saved 40k words.

public void createTable(SQLiteDatabase db, ArrayList<String> words)
{
    int i=0;


        db.execSQL(DATABASE_CREATE);

        System.out.println("created table going further");

        for( i=0; i < words.size();i++)
        {
            String[] pair=words.get(i).split(",");

            insertWord(pair[0].trim(), Integer.parseInt(pair[1].trim()), db);
            System.out.println(i++);            
        }
        System.out.println("in database  "+i+" words are there in db");     
}

I don't know whats going on here.

도움이 되었습니까?

해결책

You are incrementing i twice, one in the for and one in the print statement, change this to

for( i=0; i < words.size();i++)
    {
        String[] pair=words.get(i).split(",");

        insertWord(pair[0].trim(), Integer.parseInt(pair[1].trim()), db);
        System.out.println(i);            
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top