Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android中的compileStatement或db.insert大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_874_2@
我想多次将记录插入表中,我可以选择使用COR_955_11845@pileStatement或使用db.insert,如下所示.

String tableNAME = "table"; //fields in table: id,name
sqliteStatement statement = db.compileStatement("INSERT INTO "+TABLename+" VALUES(?,?);");  
statement.bindLong(1,666);  
statement.bindString(2,"john");
statement.executeinsert();

要么

String tableNAME = "table";
ContentValues values = new ContentValues();
values.put("id",666);
values.put("name","john");
db.insert(TABLename,null,values);

一个应该是最佳的?

编辑:-
我正在运行的应用程序是单线程的.

@H_874_2@

@R_403_1964@

insert()在每次调用时编译sql,而compileStatement()方法只编译一次sql.当多次使用具有不同绑定参数的相同sql时,compileStatement()方法执行的工作更少,速度更快.

此外,虑在事务中包装插入以减少等待I / O所花费的时间.

@H_874_2@ @H_874_2@
@H_874_2@
@H_874_2@

大佬总结

以上是大佬教程为你收集整理的android中的compileStatement或db.insert全部内容,希望文章能够帮你解决android中的compileStatement或db.insert所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。