Android Phone Development: SQLite database can be generated, but cannot create form

Source: Internet
Author: User
Tags sqlite database

1  Public classMydbhelperextendsSqliteopenhelper {2     //The database file is in the SD card, you must use the fully qualified name!!! Default path in/data/data/databases/testdbinsd.sqlite, but private data cannot be seen outside-unless root. 3     Private Static FinalString sql_name = "/sdcard/wang.sqlite";//The database name. //environment.getexternalstoragedirectory (). GetPath () + "Testdbinsd.sqlite";//4     Private Static FinalString main_data_table_name = "Wang";//The table name. 5     Private Static FinalString main_data_id = "ID";//4 fields of a table6     Private Static FinalString main_data_name = "NAME";7     Private Static FinalString main_data_sex = "SEX";8     Private Static FinalString Main_data_grade = "GRADE";9 Ten     //Construction Method One      PublicMydbhelper (Context context) { A         Super(Context, Sql_name,NULL, 1); -  - This step is fine. the  - @Override -      Public voidonCreate (Sqlitedatabase db) { -         //Build Table +String s = "CREATE TABLE person (id INTEGER PRIMARY KEY autoincrement, name VARCHAR (a), age SMALLINT);"; - Db.execsql (s); +Db.execsql ("CREATE TABLE IF not EXISTS person" + "(_id integer PRIMARY KEY autoincrement, name VARCHAR, age INTEGER, info TEXT) "); A}
This part of the problem I think has not been implemented, and later verified that it did not execute.

This part of the card for a long time, later can only find
Sqliteopenhelper of the use of the method, found
    1. Creates a Databasehelper object that only executes this sentence is not created or opened by the connected
    2. Databasehelper dbhelper = new Databasehelper (sqliteactivity. This,
    3. "test_yangyz_db");
    4. a connection is created or opened only after the Databasehelper getwritabledatabase () method or the Getreadabledatabase () method is called

Only when you open or create a connection will call Oncreat, the letter is not as good as the book, many online tutorials are .....

Android Phone Development: SQLite database can be generated, but cannot create form

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.