Reputation: 123
hello everyone i have a problem with multiple insert statements, i need to insert many records.i have written in this way but the records are not getting inserted into "userbill" table . help me??
.. here is the code:
SQLiteDatabase db = mySQLiteHelper.getWritableDatabase();
String sql = "insert into userbill (billid, userid, date, amount, bill_status) values (?, ?, ?, ?, ?)";
db.beginTransaction();
SQLiteStatement st = db.compileStatement(sql);
try{
for(int i=0;i<Userid.length;i++)
{
st.bindLong(1, billid);
st.bindString(2, Userid[i]);
st.bindString(3, due_date);
st.bindDouble(4, amount/Userid.length);
st.bindString(5, "Due");
long entryID = st.executeInsert();
st.clearBindings();
}
db.setTransactionSuccessful();
}
catch(Exception e)
{
//e.printStackTrace();
Log.e("MYAPP", "exception", e);
}
finally
{
db.endTransaction();
}
db.close();
logcat:
09-05 13:12:48.610: D/dalvikvm(7982): GC_FOR_ALLOC freed 314K, 10% free 5030K/5568K, paused 17ms, total 18ms
09-05 13:12:48.610: I/dalvikvm-heap(7982): Grow heap (frag case) to 6.181MB for 1127532-byte allocation
09-05 13:12:48.614: D/dalvikvm(7982): GC_FOR_ALLOC freed 2K, 9% free 6129K/6672K, paused 5ms, total 5ms
09-05 13:12:48.710: W/EGL_genymotion(7982): eglSurfaceAttrib not implemented
09-05 13:12:57.014: I/SQLiteConnectionPool(7982): The connection pool for /data/data/com.perfect12.app2maintain/databases/AMTDB has been closed but there are still 1 connections in use. They will be closed as they are released back to the pool.
09-05 13:12:57.286: W/EGL_genymotion(7982): eglSurfaceAttrib not implemented
Upvotes: 0
Views: 826