简体   繁体   English

将大量数据插入android sqlite数据库?

[英]Inserting large amount of data into android sqlite database?

I have a large amount of data i want to import into one sqlite database. 我有大量的数据要导入到一个sqlite数据库中。 4column and 150 rows. 4列和150行。 Currently the data is in a excel spreadsheet. 当前数据在excel电子表格中。

How can i import it into my android application? 如何将其导入我的android应用程序?

    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");

} 

This is how i have inserted two rows into my DB, but i dont want to have to do this for 150? 这就是我在数据库中插入两行的方式,但是我不想为150行吗?

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

You can load database on your desktop using any of db console, add it to resources and replace db file created by DbHelper with your own file. 您可以使用任何一个数据库控制台在桌面上加载数据库,将其添加到资源中,并将DbHelper创建的数据库文件替换为您自己的文件。 If you use Motodev it will be much easier. 如果您使用Motodev,它将更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM