Menu

Hadi's first version released

What is Hadi:

Hadi is an Android ORM Framework. It makes SQLite using in Android easy and simple. Hadi is and open source project.
You can use it free, change it and even re-publish it.

How to use Hadi:

  1. Import Hadi libary(hadi_libary/hadi_sdk.jar) into your Android project.
  2. Edit your AndroidManifest.xml

    Add attribute "android:name" into element application, it looks like this:
    <application android:name="com.the9tcat.hadi.HadiApplication" android:icon="@drawable/icon" android:label="@string/app_name">
    Define your database name and version under emlement Application, it looks like this:
    <application android:name="com.the9tcat.hadi.HadiApplication" android:icon="@drawable/icon" android:label="@string/app_name">
    <meta-data android:name="Hadi_DB_NAME" android:value="demo.db"/>
    <meta-data android:name="Hadi_DB_VERSION" android:value="1"/>

  3. Write your table's model class:

    import com.the9tcat.hadi.annotation.Column;
    import com.the9tcat.hadi.annotation.Table;

    @Table(name="Hello") //define your table's name
    public class Book{

    @Column(autoincrement=true)
    public int id;
    // define the table's column
    @Column(name="sn")
    public String sn;
    
    @Column(name = "")
    public String name;
    

    }

  4. Use DefaultDAO to insert,update,select data:

    DefaultDAO dao = new DefaultDAO(this); // "this" is android context
    /** for save data to database */
    Book b1 = new Book();
    b1.name = "Who Moved My Cheese";
    b1.sn = "sn123456789";
    dao.insert(b1);
    
  5. You can find all the example codes from demo.

Posted by 9tcat 2011-09-07 Labels: Hadi ORM SQLite Android Database

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.