Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while testing SQLite

 
Abhinay imandi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

I'm new to Android Development and I'm working with SQLite for my application.

When I run the app in the VM or in my handheld device when I'm inserting data into the table i'm getting a loop of an error/warning stating like this

08-15 03:43:10.180 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5520K, 49% free 6702K/12928K, paused 13ms, total 13ms
08-15 03:43:10.230 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5492K, 49% free 6697K/12928K, paused 13ms, total 13ms
08-15 03:43:10.270 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5452K, 49% free 6708K/12928K, paused 14ms, total 14ms
<<
08-15 03:43:10.310 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5454K, 49% free 6710K/12928K, paused 12ms, total 12ms
08-15 03:43:10.340 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5466K, 49% free 6700K/12928K, paused 11ms, total 11ms
08-15 03:43:10.370 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5414K, 49% free 6714K/12928K, paused 12ms, total 12ms
08-15 03:43:10.410 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5401K, 48% free 6723K/12928K, paused 12ms, total 12ms
08-15 03:43:10.440 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5417K, 49% free 6703K/12928K, paused 12ms, total 12ms
08-15 03:43:10.471 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5422K, 49% free 6704K/12928K, paused 12ms, total 12ms
08-15 03:43:10.511 20006-20006/com.example.miracle.sqlexample D/dalvikvm: GC_FOR_ALLOC freed 5421K, 49% free 6705K/12928K, paused 13ms, total 13ms


and this is getting repeated untill I quit the application.
below is the source code that I'm using for.

MainActivity.java


DBHelper.java

please provide me with your suggestions.

Thanks,
Abhinay
 
Ron McLeod
Bartender
Pie
Posts: 1049
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those messages are not errors, but they do indicate that garbage is being is continuously being collected, and that shouldn't be with this application.

Check your DBHelper#printDb method.  Inside your while loop, you are never moving to the next row, so your code is using the value of the first row over and over, creating new objects each time.  The check to see if the cursor is pointing to after the last row will always return false so the code will never exit the loop.

Also - you should not be closing the database in the insertEmp and printDB methods - leave it open until the application is stopped.

And - the delEmp and insertEmp always return true, regardless of whether they were successful or not - check the return values for insert and delete to determine if the database operations were successful or not.
 
Abhinay imandi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ron. It's working now.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic