Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

Like Tree1Likes
  • 1 Post By zoorroo4

test: Reply
 
LinkBack Thread Tools
Old December 26th, 2012, 06:18 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 6
 
Device(s): Samsung Galaxy S3
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Crashes on database.query?

Im making an app that's using an database. Its only reading data from it so im not using an adapter. Heres the vital parts of the code.

[HIGH] try
{
db = SQLiteDatabase.openDatabase(p, null, SQLiteDatabase.OPEN_READONLY);
}
catch(SQLiteException e)
{
Log.w(TAG, "Didnt find db");
}

String[] columns = {"_id", "QUESTION", "QUESTION TYPE", "ANSWER", "CATEGORY", "OPTIONABLE IMG NAME", "CATEGORY_URL", "ANSWER ALTERNATIVES"};
Cursor c;
c = db.query("TABLE_1", columns, null, null, null, null, null);[/HIGH]

I debugged and found that it crashes on the line [HIGH] c = db.query("TABLE_1", columns, null, null, null, null, null);[/HIGH]
Ive been trying to figure out why but i havent found a reason. I know that the database is there and that the table exists in it so why is it crashing?

Does anyone here have a clue?

zoorroo4 is offline  
Reply With Quote
sponsored links
Old December 26th, 2012, 08:39 AM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

What does the logcat output say?
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
Old December 26th, 2012, 09:41 AM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 6
 
Device(s): Samsung Galaxy S3
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jonbonazza View Post
What does the logcat output say?
I tried to catch the sqliteexception when calling database.query. When i printed it out to logcat it said something about syntax errors. Then i realized that i cant have spaces in my table names. WHich i had (my table werent called TABLE_1, that was just an example). When i exchanged all the spaces to _ signs it worked perfectly. So my problem is now fixed
jonbonazza likes this.
zoorroo4 is offline  
Reply With Quote
Old December 26th, 2012, 02:14 PM   #4 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

Excellent. =)
jonbonazza is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 01:39 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.