Written in front of, this article Reprinted from http://www.eoeandroid.com/thread-81911-1-1.html
Package EOE. demo; import android. content. context; import android. database. SQLite. sqlitedatabase; import android. database. SQLite. sqliteopenhelper;/*** database version control class * sqliteopenhelper is a database version control superclass **/public class mangerdatabase extends sqliteopenhelper {Private Static final string name = "shool "; private Static final int version = 2; /***** @ Param context information * @ Param name database name * @ Param cursorfactory factory cursor factory * @ Param version database version * initialize data parameters */Public mangerdatabase (context) {// call the superclass constructor super (context, name, null, version );} /*** if no database exists, create a table structure and overwrite the superclass Creation Method * in the superclass, this method is an oncreate method which only has the method body but does not implement the body. when the user executes a call to obtain the user database management, the instance has already executed * This method exists in a superclass and is executed by getwritabledatabase () */@ overridepublic void oncreate (sqlitedatabase dB) called by this method mongodb.exe csql ("create table person (personid integer primary key autoincrement, name varchar (20), age integer, xxx integer) ");} /*** execute update. If the table exists, perform the update operation. * oldversion Old Version Number * newversio New Version Number * onupgrade creation method. The instance has been executed when the user executes the call to obtain the user database management. * the method exists in the superclass and is composed of getwritabledatabase () */@ overridepublic void onupgrade (sqlitedatabase dB, int oldversion, int newversion) called in this method {// Delete db.exe csql ("Drop table if exists person") first "); // call the method to execute the oncreate (db );}}