• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error while testing SQLite

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ron. It's working now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic