When calling the onCreate (SQLiteDatabasedb) method of SQLiteOpenHelper

Source: Internet
Author: User
NOTE: For the first time in android, call getWritableDatabase or getReadableDatabase to execute the OnCreate () method. If the table does not exist in the database, we recommend that you create the table: we recommend that you add the judgment statement CREATETABLEIFNOTEXISTS in SQL when creating a table. "Problem description: 1. related tables in the database have been created. 2. the table has been added

NOTE: For the first time in android, call getWritableDatabase or getReadableDatabase to execute the OnCreate () method. If the table does not exist in the database, we recommend that you create the table: we recommend that you add the statement create table if not exists in SQL when creating a TABLE. "Problem description: 1. related tables in the database have been created. 2. the table has been added

Note:

In android, The getWritableDatabase or getReadableDatabase method is called for the first time to execute the OnCreate () method. If the table does not exist in the database, the create operation is performed.

Suggestion:

We recommend that you add the statement "create table if not exists" to the SQL statement when creating a TABLE.

Problem description:

1. related tables have been created in the database.

2. Data already added to the table

It is always null when you look up the total number of tables...

Solution:

1. The tracking log finds that OnCreate () will be re-executed for each query and if not exists in the SQL statement is invalid. Finally, it finds that:

GetWritableDatabase performs the query operation.

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.