Ben Orchard 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?  

Use adb logcat, DDMS, or the DDMS perspective in Eclipse to get at the
Java stack trace for the exception that triggered your "stopped
unexpectedly" dialog. That stack trace should help you identify your
problem, whatever it is.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Consulting/App Development: http://commonsware.com/consulting

-- 
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.

Reply via email to