2727import android .database .sqlite .SQLiteOpenHelper ;
2828
2929import java .util .ArrayList ;
30+ import java .util .Calendar ;
3031
3132/**
3233 * Created by amitshekhar on 16/11/16.
@@ -41,6 +42,7 @@ public class ContactDBHelper extends SQLiteOpenHelper {
4142 public static final String CONTACTS_COLUMN_STREET = "street" ;
4243 public static final String CONTACTS_COLUMN_CITY = "place" ;
4344 public static final String CONTACTS_COLUMN_PHONE = "phone" ;
45+ public static final String CONTACTS_CREATED_AT = "createdAt" ;
4446
4547 public ContactDBHelper (Context context ) {
4648 super (context , DATABASE_NAME , null , 1 );
@@ -51,7 +53,7 @@ public void onCreate(SQLiteDatabase db) {
5153 // TODO Auto-generated method stub
5254 db .execSQL (
5355 "create table contacts " +
54- "(id integer primary key, name text,phone text,email text, street text,place text)"
56+ "(id integer primary key, name text,phone text,email text, street text,place text, createdAt integer )"
5557 );
5658 }
5759
@@ -70,6 +72,7 @@ public boolean insertContact(String name, String phone, String email, String str
7072 contentValues .put ("email" , email );
7173 contentValues .put ("street" , street );
7274 contentValues .put ("place" , place );
75+ contentValues .put (CONTACTS_CREATED_AT , Calendar .getInstance ().getTimeInMillis ());
7376 db .insert ("contacts" , null , contentValues );
7477 return true ;
7578 }
0 commit comments