Use of SQLite in Android

Source: Internet
Author: User

SQLite is a built-in database in Android, SQLite is a lightweight database, supports standard SQL syntax, and supports acid things.

The Sqliteopenhelper class is available in Android to help us use SQLite. SQLite is an abstract class with two abstract methods, namely onCreate () and Onupgrade (), which we must rewrite. There are also two very important example methods in Sqliteopenhelper, Getreadabledatabase () and Getwritabledatabase (). Both of these methods can create or open an existing database (open directly if the database already exists, otherwise create a new database) and return an object that can read and write to the database. The difference is that when the database is not writable (such as disk space is full) the object returned by the Getreadabledatabase () method will open the database in a read-only manner, and the Getwritabledatabase () method will have an exception.

There are two construction methods in Sqliteopenhelper that can be overridden. The general selection of the parameters of the few to rewrite. The first parameter is the context, the second parameter is the name of the database, the third parameter is the cursor of its own definition, generally we are descendants of NULL, and the fourth is the version number of the current database.

Use of SQLite in Android

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.