Explain Android data storage in detail — using SQLite database

SQLite is a relational database built-in by Android. It is a lightweight database based on files. Android provides three ways to manipulate data, shared preference, file storage and SQLite database.

SQLite database files are saved in / data / data / package_ Name / databases directory.

1、 Create and delete tables

1. Create table

The SQL statement to create the table is:

The corresponding java code is:

2. Delete table

The SQL statement is:

The corresponding java code is:

2、 Operate on records in the database

1. Insert record

Insert usage:

2. Update records

Update usage:

Eg: update the password named Bob in the table

3. Delete record

Delete usage:

Eg: delete the record of Bob

4. Query records

1. Single table query

Use sqlitedatabase. Query (7 parameters).

2. Multi table query

If the user name and password are saved in table a and the user name and other specific information are saved in table B, use sqlitequerybuilder multi table query. SQL statement:

Multi table query steps:

Instance - login through database authentication

1. Database design

The database help class is used to write the oncreate method from

2. Login interface

3. Registration interface

4. Login success interface

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can 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
分享
二维码
< <上一篇
下一篇>>