ORMLite is lightweight Java ORM supports for android Sqlite Database.The full form of ORMLite is Object Relational Mapping Lite(ORMLite).and it provides some light weight functionality to store and retrieve Java Objects.And it avoiding the complexity and more standard Object Relational Mapping.

ORMLite supports more than one database using JDBC and also sqlite with native calls to android database APIs..

ORMLite simply add objects of java using annotations.and its have powerful abstract Database Access Object classes.also provides simple and  flexible query using QueryBuilder.Auto generates SQL to create and drop database tables.and its have basic supports for database transactions.

ORMLite Supports MySQL, Postgres, Microsoft SQL Server, H2, Derby, HSQLDB, and Sqlite and can be extended to additional databases relatively easily.
Provisional support for DB2, Oracle, ODBC, and Netezza.

@DatabaseField(generatedId = true)

     private int id;

     @DatabaseField
     private String name;

     @DatabaseField 
     private String adress;

Suppose, your class is Person

public class Person {

        @DatabaseField(generatedId = true)
        private int id;
        @DatabaseField
        private String name;

 public int getId() {
       return id;
 }
 public void setId(int id) {
       this.id = id;
 }
 public String getName() {
       return name;
 }
 public void setName(String firstname) {
       this.name = firstname;
 }
}

First of All Create object of DatabaseHelper Class.

DatabaseHelper helper = new DatabaseHelper(getApplicationContext());

   Now using helper object you can add java object in ORMLite Database.

Person person = new Person(); 
person.setName(strName);

helper.addData(person); // Add Object in ORMLite Database

Now how to Retrieve Data From ORMLite Database

List<Person> list = helper.GetData();

Delete Data From ORMLite Database.

helper.deleteAll();

DownLoad Full Source Code From Here

DownLoad Source Code

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Comments

comments