When we usually use SQLite, if we have 10 tables, we have to write 10 statements, and only some of the names of the table statements need to be changed, it is time-consuming and laborious, but also error-prone, we know that when writing SQL statements are often written incorrectly, if the wrong program will be collapsed, And check 10 build statements can also, if there are 100 I'm going crazy. This article tells you how to quickly build a table by reflection.
1. We write a dbhelper inherited from Sqliteopenhelper
2.Movie entity class, the attribute in the entity class is the field in the table 3. In Mainactivity.java, add the following code 4. We data/data/the package name/databases/ Ladeng.db to see if the table is already built so that we can design the good one entity class directly and then build the corresponding database table without having to write the table statement again.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android makes it easy for SQLite to create a table with reflection