Sunday 20 July 2014

ActiveAndroid Tutorial | ActiveAndroid: Android ORM base database |Getting Started with ActiveAndroid - Part1

ActiveAndrid :                                                                               
Active Android

ActiveAndroid is an ORM (object relational mapper) . Which allows you to save(insert)
and retrieve(read) SQLite database records without even writing a single SQL statement.
Each database record is wrapped neatly into a class with methods like save().
It is same a Java Hibernate. It also based on annotation like: @Column(name="Column")  for creating column and Table(name = "Table")  for creating table .

Getting started : 
A.Now here we are going to start integrating ActiveAndroid in your project.
    1. Download the ActiveAndroid library
    2. Now generate the ActiveAndroid.jar by executing ant in root folder
    3. If you are unable to generate the jar file then download it from here

 Now, we have ActiveAndroid.jar file.  Now, we can add it inside the "libs" folder of
Android Project.    

B. Configuring Android Project with ActiveAndroid :
    1. Open the AndroidManifest.xml file located at the root directory of your Android project.

<manifest xmlns:android=""
    android:versionName="1.0" >
           android:theme="@style/AppTheme" >
             android:screenOrientation="landscape" >
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
         <meta-data android:name="AA_DB_NAME" android:value="Student.db" />
         <meta-data android:name="AA_DB_VERSION" android:value="1" />

Note:  In your manifest.xml, if you are not using any Custom Application class then the application name points to the ActiveAndroid application class as we are doing above. But if you are using any Application levele custom class then your Custom Application class must extend instead of

public class MyApplication extends { ...

And initialize and dispose ActiveAndroid in the Application class.

public class MyApplication extends {

    public void onCreate() {

    public void onTerminate() {

Note : If you want to create your db in a specific location inside your Sd Card then change below line in manifest.xml

<meta-data android:name="AA_DB_NAME" android:value="/sdcard/Student.db" />

<meta-data android:name="AA_DB_VERSION" android:value="1" />

Here, we are creating our database file inside the sd card root folder.
So that we can easily import it in Sqlite Browser .

Mukesh Kumar

Hi Guys I am from Delhi working as Web/Mobile Application Developer(Android Developer), also have knowledge of Roboelctric and Mockito ,android test driven development... Blogging has been my passion and I think blogging is one of the powerful medium to share knowledge and ideas....



Copyright @ 2013 Android Developers Blog.