Android recommends that you use rawquery for SQLite operations.

Source: Internet
Author: User

For databases on the Android platform, embedded SQLite is becoming more and more popular. For better cross-platform operations, we recommend that you use original SQL statements for direct operations, which greatly improves the code and processing efficiency, however, you must handle SQL statement exceptions.

Next, let's talk about the advantages of rawquery. We can see that the query Code uses SQL statements directly. The performance test efficiency is much faster than the class encapsulated by Android, but it cannot be used with some adapters, however, in general, the cross-platform architecture is very prominent. The following is the pseudo code for local usage, without any construction and instantiation. It is hoped that the project manager will know the advantages of rawsql in the use of Android platform.

Sqlitedatabase dB; string ARGs [] = {ID}; contentvalues CV = new contentvalues (); cv. put ("android123", ID); cursor c = dB. rawquery ("select * from table where android123 =? ", ArgS); execute the local SQL statement to query if (C. getcount ()! = 0) {// dosomething contentvalues CV = new contentvalues (); cv. put ("android123", "cwj"); dB. insert ("table", "android123", CV); // insert data string ARGs [] = {ID}; contentvalues cv2 = new contentvalues (); cv2.put ("android123 ", ID); dB. delete ("table", "android123 =? ", ArgS); // delete data}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.