简体   繁体   English

在android中执行sql查询的方法有何不同?

[英]Difference in Ways of executing sql queries in android?

android中的db.execSQL()方法和activityObject.managedQuery()方法有什么区别?

managedQuery(...) is a generic query mechanism which can be used for a variety of 'database' objects that have ContentProviders . managedQuery(...)是一种通用查询机制,可用于具有ContentProviders的各种“数据库”对象。 This can include SQLite databases, phone contacts etc etc. It can only be used to 'query' for data and not make changes to the database. 这可以包括SQLite数据库,电话联系人等等。它只能用于“查询”数据而不能更改数据库。

db.execSQL(...) is a method call directly on a SQLite database and can be used to perform any SQL operation. db.execSQL(...)是直接在SQLite数据库上进行的方法调用,可用于执行任何SQL操作。 This means not only can it 'query' (SELECT) data, but it can be used to create, alter, drop tables as well as insert, delete rows etc. 这意味着它不仅可以“查询”(SELECT)数据,还可以用于创建,更改,删除表以及插入,删除行等。

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

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