Explain in detail the addition, deletion, modification and query operations of some SQLite in Android

Data manipulation is often involved in Android development. Android itself provides four ways to store data. Including: sharepreference, SQLite, content provider, file. In Android, data is private. To realize data sharing, the correct way is to use the content provider. SQLite: SQLite is a lightweight database that supports basic SQL syntax and is often used as a data storage method. Android provides a class named sqlitedatabase for this database, which encapsulates some APIs for operating the database. Shared preference: in addition to SQLite database, another common data storage method is an XML file, which is often used to store simple parameter settings. File: it is often called file (I / O) storage method. It is commonly used to store a large amount of data, but the disadvantage is that updating data will be difficult. ContentProvider: a data storage method that can be shared by all applications in Android system. Because data is usually private among applications, this storage method is rarely used, but it is an essential storage method. For example, audio, video, pictures and address books can generally be stored in this way. Each content provider will provide a public URI (wrapped as a URI object). If an application has data to share, it needs to use the content provider to define a URI for these data, and then other applications will pass in the URI through the content provider to operate on the data.

This article is mainly about some SQLite operations and attached code.

SQLite is a lightweight database designed for embedded devices. It has only five data types: null: null value integer: integer real: floating point number text: String blob: big data

In SQLite, the Boolean and date types are not specially designed, because the boolean type can replace true and false with 0 and 1 of integer, while the date type can have the values of text, real and integer in a specific format to replace the display. In order to facilitate the operation of the date type, SQLite provides a set of functions. See the following for details: http://www.sqlite.org/lang_ Datefunc.html, such a simple data type design is more in line with the requirements of embedded devices.

The above is a simple operation of adding, deleting, modifying and querying tables, which can be modified according to the actual situation to meet the needs of the project.

The above is the whole content of this article. I hope I can give you a reference and support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>