Take a look at the logcat output... It will tell you more about the cause of the problem.
---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Thu, Mar 25, 2010 at 9:49 PM, Ben Orchard <[email protected]> wrote: > I am attempting to figure out where my code is going wrong. Any help at > all would be appreciated. I am SO frustrated about this. Here's the story. > I have code copied from this seemingly popular tutorial: > > http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ > > I've made only those alterations absolutely necessary to fit my database > and package. > > Then in the activity which calls that I have this: > > > package com.TBOM; >> >> import java.io.IOException; >> >> import android.app.Activity; >> import android.database.Cursor; >> import android.database.SQLException; >> import android.database.sqlite.SQLiteDatabase; >> import android.os.Bundle; >> import android.widget.TextView; >> >> public class Game extends Activity { >> //private DataBaseHelper myDBHelper; >> private final String MY_DB_NAME = "bom";//test >> private final String MY_DB_TABLE = "tst";//test >> public static final String KEY_Q = "title"; >> public static final String KEY_ANS1 = "Ans1"; >> public static final String KEY_ANS2 = "Ans2"; >> public static final String KEY_ANS3 = "Ans3"; >> public static final String KEY_ANS4 = "Ans4"; >> public static final String KEY_ANSKEY = "AnsKey"; >> public static final String KEY_ANSINFO = "AnsInfo"; >> public static final String KEY_ROWID = "_id"; >> >> @Override >> public void onCreate(Bundle Game) throws SQLException{ >> super.onCreate(Game); >> setContentView(R.layout.game); >> DataBaseHelper myDbHelper = new DataBaseHelper(this); >> TextView qTV = (TextView) findViewById(R.id.Qtxt); >> SQLiteDatabase myQDB = null; >> >> try { >> myDbHelper.createDataBase(); >> qTV.setText("WIN1"); >> } catch (IOException ioe) { >> qTV.setText("FAIL1"); >> throw new Error("Unable to create database"); >> >> } >> >> try { >> myDbHelper.openDataBase(); >> qTV.setText("WIN2"); >> }catch(SQLException sqle){ >> qTV.setText("FAIL2"); >> throw sqle; >> } >> >> myDbHelper.openDataBase();//test >> >> int rowId=3; >> myQDB = SQLiteDatabase.openDatabase(MY_DB_NAME, null, >> SQLiteDatabase.OPEN_READONLY); >> Cursor qCursor = myQDB.query(true, MY_DB_TABLE, new String[] >> {}, KEY_ROWID+ "="+ rowId, null,null,null, null, null); >> // mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, >> //KEY_TITLE, KEY_BODY}, KEY_ROWID + "=" + rowId, null, >> //null, null, null, null); >> int qColumn = qCursor.getColumnIndex(KEY_Q); >> //int idColumn = qCursor.getColumnIndex(KEY_ROWID); >> if(qCursor != null){ >> String qString = qCursor.getString(qColumn); >> //int row = qCursor.getInt(idColumn); >> qTV.setText(qString); >> } >> >> >> >> >> } >> >> } >> >> > > When I try to run this in the emulator, it tells me that the application > has 'stopped unexpectedly". Can anyone please explain to me what is going > on? For the record everything was fine with the code just before teh line > " myDbHelper.openDataBase();//test". Everything from there on (essentially > when I attempt to read data from teh db). > > Again, I am so confused and lost that I just don't know what to do. You > can infer the structure of the db from the KEY_* variables that I've > included. > > Thanks in advance. > > Ben > > -- > I have no bit of wisdom to include as a signature. > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected]<android-beginners%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > > To unsubscribe from this group, send email to android-beginners+ > unsubscribegooglegroups.com or reply to this email with the words "REMOVE > ME" as the subject. > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe from this group, send email to android-beginners+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

