将大量数据插入android sqlite数据库? [英] Inserting large amount of data into android sqlite database?

查看:35
本文介绍了将大量数据插入android sqlite数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量数据要导入到一个 sqlite 数据库中.4 列和 150 行.目前,数据在 Excel 电子表格中.

I have a large amount of data i want to import into one sqlite database. 4column and 150 rows. Currently the data is in a excel spreadsheet.

如何将其导入到我的安卓应用程序中?

How can i import it into my android application?

    String SQL = "create table " + TABLE + "( " 
        + BaseColumns._ID
        + " integer primary key, " 
        + Column1+ " text, "
        + Column2+ " text, "
        + Column3+ " text, " 
        + Column4+ " text);";
        db.execSQL(SQL);        

        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");
        db.insert(DBAdapter.TABLE, null, values);

        ContentValues values2 = new ContentValues();
        values2.put(DBAdapter.Column1,  "P");
        values2.put(DBAdapter.Column2,  "other");
        values2.put(DBAdapter.Column3,  "other");
        values2.put(DBAdapter.Column4,  "345");

} 

这就是我在我的数据库中插入两行的方式,但我不想这样做 150 行?

This is how i have inserted two rows into my DB, but i dont want to have to do this for 150?

推荐答案

您可以将信息存储在 CSV 文件中,然后读取该文件并将每一行存储在 sqlite 中.

You could store the information on a CSV file, then read the file and store each row in sqlite.

这篇关于将大量数据插入android sqlite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆