Using the reflection mechanism to create a SQLite database

Source: Internet
Author: User
Tags sqlite sqlite database

Wirelessly building a library by reflection

Using the reflection mechanism of Java, we can get a list of the methods in the object, the parameter list and the corresponding values.

1. Model Layer
Database Layer DAO
Business Tiers
Database base class Base
2. Implementation steps
(1) Write a database helper class
1) Define the interface to enable reflection to be invoked, perform read and write operations
2) Use the singleton mode to construct the private construction method first, then judge

(2) Create an entity class, where the property is a field in the datasheet
The method of constructing table, updating, writing and adding and adding and deleting in DAO layer
(3)
In base class base, the Config class declares the database name, the database name
Defines a private construction method used by the outside world to instantiate objects directly using new
Returns the database name, returns the database version
(4) Materialized Reflection tool class

(5) View
View in Ddms, data/data/package name/databases/database name

Using the reflection mechanism to create a SQLite database

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.