Android sqlite批量插入数据

String sql = "insert into bus_line_station(direct,line_name,sno,station_name) values(?,?,?,?)";
        SQLiteStatement stat = db.compileStatement(sql);
        db.beginTransaction();
        for (Station line : busLines) {
            stat.bindLong(1, line.direct);
            stat.bindString(2, line.lineName);
            stat.bindLong(3, line.sno);
            stat.bindString(4, line.stationName);
            stat.executeInsert();
        }
        db.setTransactionSuccessful();
        db.endTransaction();
        db.close();
发布了18 篇原创文章 · 获赞 4 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/caoming51021/article/details/44411431
今日推荐