First introduce a few basic conceptual knowledge: What is SQLite: SQLite is a lightweight database. It is designed to be embedded, and it takes up very few resources. In an embedded device, it only requires a few hundred KB !!!!! Features of SQLite: Lightweight You only need to bring a dynamic library to use SQLite, you can enjoy all its functions, and the size of the dynamic library wants to be small. Independence The core engine of the SQLite database does not need to rely on third-party software, nor does it require so-called "installation". Isolation All information in the SQLite database (such as tables, views, triggers, etc.) are contained in a folder, which is convenient for management and maintenance. Cross-platform SQLite currently supports most operating systems, not only computer operating systems but also many mobile phone systems, such as Android. Multilingual interface SQLite database supports multi-language programming interface. safety The SQLite database implements independent transaction processing through database-level exclusivity and shared locks. This means that multiple processes can read data from the same database at the same time, but only one can write data. advantage: 1. Can store more data. 2. Able to store database files in SD card! What is SQLiteDatabase? A SQLiteDatabase instance represents a SQLite database. Through some methods of the SQLiteDatabase instance, we can execute SQL statements to add, delete, check, and modify the database. It should be noted that the database is private to an application, and in an application, the database name is also unique. What is SQLiteOpenHelper? According to this name, we can see that this class is an auxiliary class. This class mainly generates a database and manages the version of the database. When calling the getWritableDatabase () or getReadableDatabase () method of this class in the program, if there is no data at that time, the Android system will automatically generate a database. SQLiteOpenHelper is an abstract class, we usually need to inherit it and implement the three functions inside, What is the ContentValues ​​class? The ContentValues ​​class is similar to Hashmap / Hashtable, it is also responsible for storing some name-value pairs, but the name of the name-value pair it stores is String type, and the value is the basic type. What is Cursor? Cursor is a very useful interface in Android. Through Cursor, we can perform random read and write access to the result set queried from the database. OK, the basic knowledge is introduced here, and the code starts below: still according to my usual style, the explanation of the code has been commented and explained in time in the code! By the way, take a screenshot of the project: First give the xml: view plaincopy to clipboardprint? ········· 10 ······· 20 ······· 30 ······· 40 ······· 50 ···· ··· 60 ········ 70 ······ 80 ········ 90 ····· 100 ········ ····· 120 ······· 130 ······ 140 ······· 150 "? Xml version =" 1.0 "encoding =" utf-8 "?" "LinearLayout xmlns: android =" http://schemas.android.com/apk/res/android " android: orientaTIon = “verTIcal†android: layout_width = “fill_parent†android: layout_height = “fill_parentâ€ã€‹ "TextView android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “SQL practice! (If you use the SD card to store data, in order to ensure normal operation, please click to create a table and then operate)†android: textSize = “20sp†android: textColor = “# ff0000†android: id = “@ + id / tv_TItle†/》 "Button android: id =" @ + id / sql_addOne "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “Insert a recordâ€ã€‹ 《/ Button》 "Button android: id =" @ + id / sql_check "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “Query databaseâ€ã€‹ // Button》 "Button android: id =" @ + id / sql_edit "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “Modify a recordâ€ã€‹ 《/ Button》 "Button android: id =" @ + id / sql_deleteOne "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “Delete a recordâ€ã€‹ 《/ Button》 "Button android: id =" @ + id / sql_deleteTable "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “Delete data formâ€ã€‹ 《/ Button》 "Button android: id =" @ + id / sql_newTable "android: layout_width =" fill_parent " android: layout_height = “wrap_content†android: text = “New data formâ€ã€‹ã€‹ / Button》 "/ LinearLayout" High Frequency AC Power Supply Adapter Power Regulated,Ac To Dc Regulated Power Supply,High Voltage Regulated Power Supply,High Voltage High Frequency Power Supply Yangzhou IdealTek Electronics Co., Ltd. , https://www.idealtekpower.com