Skip to content

xiaosunzhu/storm-gen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

storm-gen

Simple ORM for Android SQLite

Community

Use the issue tracker to report bugs or request enhancements, and StackOverflow with tag storm-gen for assistance. Join the storm-gen G+ community for project news and feature discussion.

Setup

  1. Download storm-api.jar from the latest release and add to your Android project's libs folder so it will be on the project's build path.
  2. Download storm-apt.jar from the latest release and add to your annotation factory classpath (in Eclipse, project properties | Java Compiler > Annotation Processing > Factory Path). Also check the box to enable annotation processing.

Basic Usage

  1. Create a new class that extends com.turbomanage.storm.DatabaseHelper (it's in the storm-api jar).
  2. Add @Database and supply a database name and version example
  3. Override getUpgradeStrategy() to choose one of the available strategies (DROP_CREATE for new projects)
  4. Create a POJO class you want to persist to the database
  5. Make sure it has a field of type long named "id" or annotated with @Id
  6. Add the @Entity annotation to the class example

You'll see 3 generated classes under .apt_generated (you might need to unfilter hidden resources in your IDE to see it):

  • a DbFactory class
  • a Dao class
  • a Table class

You can use the DAO like this:

PersonDao dao = new PersonDao(getContext());
long id = dao.insert(new Person());
Person person = dao.get(id);

For more info, see the unit tests and the resources on the project home page.

About

Simple ORM for Android SQLite

Resources

License

Stars

Watchers

Forks

Packages

No packages published