SQLite database for Android Development

Source: Internet
Author: User
Tags sqlite database

 

SQLite database for Android Development

As shown in the preceding example, run the following command first:

When we click each button, the corresponding operation prompt will be output in the logcat log, as shown below:

The following describes the complete project development process.

1. Create an android project named SQLite.

2. Modify the layout file main. xml. The Code is as follows:

3. Here we create a database operation helper class sqliteopenhelper. java. This class can complete the creation, Open Database and various database operations. Here we can create a database and a table. The specific code is as follows:

4. Modify the activity code. Here we mainly perform some simple operations on the database. The Code is as follows:

5. after the project is completed, click execute to obtain the above results.

Here, I need to talk about it. If you want to see the database you created, you can use either of the following methods:

First, go to cmd to view the database. The specific steps are as follows:

(1) Run-> Enter cmd-> ADB shell, and then input ls, the following results will be displayed:

(2) run the CD command to enter the directory data. You need to repeat the operation twice here. After ls, there will be a lot of packages, of course, there are also projects you have created, due to the reason of the screen I only part of the screenshot. As follows:

(3) Find the package of your project, use CD to enter, and then ls, databases will appear, and then enter databases. Then ls will show the database you created. As follows:

(4) Go to the database and view the data in the created table and table. here we need to use sqlite3 for operations,

The procedure is as follows:

Second, check in file explorer in ddms of eclipse. The specific operations are as follows:

Go to data> DATA> Find the project package> enter the package> databases to find the created database.

Now, the entire database operation is complete. Thank you!

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.