Skip to content

Commit 10626b1

Browse files
author
Vinayaga Sundar
committed
Fixed the large integer value is overflow issue
1 parent aef1704 commit 10626b1

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

app/src/main/java/com/sample/database/ContactDBHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.database.sqlite.SQLiteOpenHelper;
2828

2929
import 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
}

debug-db/src/main/java/com/amitshekhar/server/ClientServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ private Response query(String sql) {
425425
row.add(cursor.getFloat(i));
426426
break;
427427
case Cursor.FIELD_TYPE_INTEGER:
428-
row.add(cursor.getInt(i));
428+
row.add(cursor.getLong(i));
429429
break;
430430
case Cursor.FIELD_TYPE_STRING:
431431
row.add(cursor.getString(i));

0 commit comments

Comments
 (0)