Android SQLite database BASICS (1 continued), androidsqlite
Supplementary note, in the previous article, I have joined the following content, have not read the first article, you can directly read the first article can be (http://www.cnblogs.com/flylin/p/qq_980542577.html ). Read this article.
Create a test class to test whether the Code mentioned in the previous article is correct:
Add the following code to the manifest node of AndroidManifest. xml in the project:
<Instrumentation
Android: name = "android. test. InstrumentationTestRunner"
Android: targetPackage = "package name"/>
Add the following code to the application node of the manifest node:
<Uses-library android: name = "android. test. runner"/>
The result is as follows:
In the test class, the code I wrote is as follows:
Package com. example. sqllites. dbs. test;
Import com. example. sqllites. dbs. sqlite_Persondb;
Import android. test. AndroidTestCase;
/**
* Test class
* White box testing
* @ Author Lin
*
*/
Public class sqliteTest extends AndroidTestCase {
Public void testSQLite () throws Exception {
/**
* If only objects are declared, the database is not created, similar to File.
*/
Sqlite_Persondb sqlite_per = new sqlite_Persondb (getContext ());
/**
* Use the following code to create a function
*/
Sqlite_per.getWritableDatabase ();
}
}
The running result will get two database files, which are opened by sqlite3, for example: