• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

populating expandablelistview from sqlite database application force closes

 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the tutorial on AndroidHive for expandablelistview and i want to populate it from a sqlite table.
MainActivity.java


my datamanager



The application force closes .Can anyone check whether i have used the sql in rawquery properly.Please help.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the full stack trace from the logcat output. Examining that should always be your first step in debugging a forced app close.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A force close can happen for too many reasons to start guessing. You need to view the LogCat output and see what the error is so you know what the problem is and where it occurs.


Using DDMS from Eclipse (or other IDE): http://developer.android.com/tools/debugging/ddms.html
Using adt to view LogCat: http://developer.android.com/tools/debugging/debugging-log.html
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that nice how it points directly not only at the line of code *where* the errors occurs, but even gives you clues *what* the problem is :-)

So, the problem is with your SQL statement - is CATEGORY a varchar of some kind? If so, how to do you need to handle varchar literal values in SQL statements?
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will this work??

 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above ran without force closing.But i don't see any data when i click the Expandable list view Please help...
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The word Entertainment was actually entertainment in the table but still it doesnt work...
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
achuthan mukundarajan wrote:The word Entertainment was actually entertainment in the table but still it doesnt work...

Now you have to figure out why it doesn't work. What lines of code get executed? What happens if you put data in the list without using the database? What data is returned from your database query? This is where adding your own log lines, and/or running the application in debug
mode with break points can help you figure out exactly what is happening with your execution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic