Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

To insert large amount of data in android SQLite Database

I am new in Android Development.

Currently, working with SQLite Database in Android.

My problem is that I have a large amount of data which I have to store in SQLite Database in Android.

There are 2 tables: One having 14927 rows and the other one has 9903 rows.

Currently the database in sql. And I have copy these data in excel sheet but don't understand how can I import these data in SQLite Database.

I go through the following link:

Inserting large amount of data into android sqlite database?

Here, the solution is posted regarding CSV File. But want to know other ways of doing this.

Please let me know what is the best way to import such a large data in Android.

Please help me. Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Do Like This

SQLiteDatabase sd;
    sd.beginTransaction();


        for (int i = 0; i < data.size(); i++) {
            ContentValues values = new ContentValues();
            values.put(DBAdapter.Column1,  "HP");
            values.put(DBAdapter.Column2,  "qw");
            values.put(DBAdapter.Column3,  "5280");
            values.put(DBAdapter.Column4,  "345, 546");
            sd.insert(DBAdapter.TABLE, null, values);
            sd.insertWithOnConflict(tableName, null, values, SQLiteDatabase.CONFLICT_IGNORE);

        }

    sd.setTransactionSuccessful();
    sd.endTransaction();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...