1. MOBILE/data/ApplicationsProgramCreate a database under the package name/directory
If the size of the created database is small, you can use the sqliteopenhelper class that comes with Android to directly generate the database on the mobile phone
/Data/application package name/directory. The method is as follows:
Write a mysqliteopenhelper class that inherits from the sqliteopenhelper class and overwrites the oncreate and onupdate methods.
Public class mydatabasehelper extends mysqliteopenhelper {
// Database Name
Public final static string database_name = "DB ";
// Database version
Public final static int database_version = 1;
Mydatabasehelper (final context ){
Super (context, database_name, null, database_version );
}
@ Override
Public void oncreate (sqlitedatabase dB ){
// Create a database table
}
@ Override
Public void onupgrade (sqlitedatabase dB, int oldversion, int newversion ){
If (newversion! = Oldversion ){
// Update the database
}
Oldversion = newversion;
}
}
However, the database generated using this method is saved in the/data folder of the mobile phone, which brings two problems: 1. If the storage of the mobile phone itself
The size of the created database is limited when the space is small. 2. If the root permission of the mobile phone cannot be obtained, the created database cannot be directly viewed.
File. Given the above problems, it is a good choice to put the database on the memory card.
NextArticleThis section describes how to create a database on a memory card.