3

I'm a beginner on android developemment and I follow tutorials of thenewboston website for learning. But I don't see why the code doesn't work there, when I check on the creation of my database I see nothing strange. Can you help me please? I will be glad to understand the mistakes and continue my learning on android developement.

When I launch my avd and i click on update i have "finnaly" "good" but there is also an error that is logged. And when I click on view to see my data, A dialog pops with message "Unfortunately, SQLiteExample has stopped"

Sorry for the long post but like i'm a begginner I give you all the code that i can give you.

SQLiteExample.java

package exercice.thenewboston;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SQLiteExample extends Activity implements OnClickListener
{
    Button  sqlUpdate, sqlView;
    EditText    sqlName, sqlHotness;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        sqlUpdate = (Button) findViewById(R.id.bSQLUpdate);
        sqlName = (EditText) findViewById(R.id.etSQLName);
        sqlHotness = (EditText) findViewById(R.id.etSQLHotness);

        sqlView = (Button) findViewById(R.id.bSQLopenView);
        sqlView.setOnClickListener(this);
        sqlUpdate.setOnClickListener(this);
    }

    public void onClick(View arg0){
        switch (arg0.getId())
        {
            case R.id.bSQLUpdate:

            boolean didItWork = true;
            try
            {
                String name = sqlName.getText().toString();
                String hotness = sqlHotness.getText().toString();

                HotOrNot entry = new HotOrNot(SQLiteExample.this);
                entry.open();
                entry.createEntry(name, hotness);
                entry.close();
            }
            catch(Exception e )
            {
                didItWork = false;
                String error = e.toString();
                Dialog d = new Dialog(this);
                d.setTitle("CATCH");
                TextView tv = new TextView(this);
                tv.setText(error);
                d.setContentView(tv);
                d.show();
            }

            finally
            {
                if (didItWork)
                {
                    Dialog d = new Dialog(this);
                    d.setTitle("FINALLY");
                    TextView tv = new TextView(this);
                    tv.setText("GOOD");
                    d.setContentView(tv);
                    d.show();
                }
            }
            break;
            case R.id.bSQLopenView:
                Intent i = new Intent("exercice.thenewboston.SQLVIEW");
                startActivity(i);
            break;
        }
    }
    }

HotOrNot.java

package exercice.thenewboston;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class HotOrNot
{
    public static final String  KEY_ROWID           = "_id";
    public static final String  KEY_NAME            = "persons_name";
    public static final String  KEY_HOTNESS         = "persons_hotness";

    private static final String DATABASE_NAME       = "HotOrNotdb";
    private static final String DATABASE_TABLE      = "peopleTable";
    private static final int    DATABASE_VERSION    = 1;

    private DbHelper            ourHelper;
    private final Context       ourContext;
    private SQLiteDatabase      ourDatabase;

    private static class DbHelper extends SQLiteOpenHelper
    {

        public DbHelper(Context context)
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db)
        {
            db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" + KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_NAME + " TEXT NOT NULL, " + KEY_HOTNESS + " TEXT NOT NULL);");
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
        {
            db.execSQL("DROP TABLE IF EXITS " + DATABASE_TABLE);
            onCreate(db);
        }
    }

    public HotOrNot(Context c)
    {
        ourContext = c;
    }

    public HotOrNot open() throws SQLException
    {
        ourHelper = new DbHelper(ourContext);
        ourDatabase = ourHelper.getWritableDatabase();
        return this;
    }

    public void close()
    {
        ourHelper.close();
    }

    public long createEntry(String name, String hotness)
    {
        ContentValues cv = new ContentValues();
        cv.put(KEY_NAME, name);
        cv.put(KEY_HOTNESS, hotness);
        return ourDatabase.insert(DATABASE_TABLE, null, cv);
    }

    public String getData()
    {
        String[] columns = new String[]{ KEY_ROWID, KEY_NAME, KEY_HOTNESS};
        Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
        String result = "";

        int iRow = c.getColumnIndex(KEY_ROWID);
        int iName = c.getColumnIndex(KEY_NAME);
        int iHotness = c.getColumnIndex(KEY_HOTNESS);

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
        {
            result = result + c.getString(iRow) + " " + c.getString(iName) + " " + c.getString(iHotness) + "\n";
        }

        return result;

    }
}

SQLView.java

package exercice.thenewboston;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class SQLView extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sqlview);
        TextView tv  = (TextView) findViewById(R.id.tvSQLinfo);
        HotOrNot info = new HotOrNot(this);
        info.open();
        String data = info.getData();
        info.close();
        tv.setText(data);
    }
}

res -> layout -> main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/TextView1"
        android:text="Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </TextView>

    <EditText
        android:id="@+id/etSQLName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </EditText>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hotness scale 1 to 10">
    </TextView>

    <EditText
        android:id="@+id/etSQLHotness"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </EditText>

    <Button
        android:id="@+id/bSQLUpdate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Update SQLite Database" />


    <Button
        android:id="@+id/bSQLopenView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="View">

    </Button>

</LinearLayout>

res --> layout --> sqlview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id= "@+id/tableLayout1">

        <TableRow>
           <TextView android:text="Names"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1">
           </TextView>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Hotness"
                android:layout_weight="1">
            </TextView>

        </TableRow>

    </TableLayout>

    <TextView
        android:id="@+id/tvSQLinfo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="get info from db">
    </TextView>

</LinearLayout>

logs when i launch, then put datas on fied, click on update and after click on view

04-29 16:01:58.217: I/dalvikvm(530): threadid=3: reacting to signal 3
04-29 16:01:58.277: I/dalvikvm(530): Wrote stack traces to '/data/anr/traces.txt'
04-29 16:01:58.627: D/gralloc_goldfish(530): Emulator without GPU emulation detected.
04-29 16:01:58.737: I/dalvikvm(530): threadid=3: reacting to signal 3
04-29 16:01:58.757: I/dalvikvm(530): Wrote stack traces to '/data/anr/traces.txt'
04-29 16:02:20.867: I/SqliteDatabaseCpp(530): sqlite returned: error code = 1, msg = table peopleTable has no column named persons_hotness, db=/data/data/exercice.thenewboston/databases/HotOrNotdb
04-29 16:02:20.945: E/SQLiteDatabase(530): Error inserting persons_hotness=4 persons_name=rt
04-29 16:02:20.945: E/SQLiteDatabase(530): android.database.sqlite.SQLiteException: table peopleTable has no column named persons_hotness: , while compiling: INSERT INTO peopleTable(persons_hotness,persons_name) VALUES (?,?)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:112)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1718)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1591)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at exercice.thenewboston.HotOrNot.createEntry(HotOrNot.java:69)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at exercice.thenewboston.SQLiteExample.onClick(SQLiteExample.java:46)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.view.View.performClick(View.java:3511)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.view.View$PerformClick.run(View.java:14105)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.os.Handler.handleCallback(Handler.java:605)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.os.Looper.loop(Looper.java:137)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at android.app.ActivityThread.main(ActivityThread.java:4424)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at java.lang.reflect.Method.invoke(Method.java:511)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-29 16:02:20.945: E/SQLiteDatabase(530):  at dalvik.system.NativeStart.main(Native Method)
04-29 16:02:26.688: I/SqliteDatabaseCpp(530): sqlite returned: error code = 1, msg = no such column: persons_hotness, db=/data/data/exercice.thenewboston/databases/HotOrNotdb
04-29 16:02:26.698: D/AndroidRuntime(530): Shutting down VM
04-29 16:02:26.698: W/dalvikvm(530): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-29 16:02:26.848: E/AndroidRuntime(530): FATAL EXCEPTION: main
04-29 16:02:26.848: E/AndroidRuntime(530): java.lang.RuntimeException: Unable to start activity ComponentInfo{exercice.thenewboston/exercice.thenewboston.SQLView}: android.database.sqlite.SQLiteException: no such column: persons_hotness: , while compiling: SELECT _id, persons_name, persons_hotness FROM peopleTable
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.os.Looper.loop(Looper.java:137)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread.main(ActivityThread.java:4424)
04-29 16:02:26.848: E/AndroidRuntime(530):  at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:02:26.848: E/AndroidRuntime(530):  at java.lang.reflect.Method.invoke(Method.java:511)
04-29 16:02:26.848: E/AndroidRuntime(530):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-29 16:02:26.848: E/AndroidRuntime(530):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-29 16:02:26.848: E/AndroidRuntime(530):  at dalvik.system.NativeStart.main(Native Method)
04-29 16:02:26.848: E/AndroidRuntime(530): Caused by: android.database.sqlite.SQLiteException: no such column: persons_hotness: , while compiling: SELECT _id, persons_name, persons_hotness FROM peopleTable
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:127)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:53)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1564)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1449)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1405)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1485)
04-29 16:02:26.848: E/AndroidRuntime(530):  at exercice.thenewboston.HotOrNot.getData(HotOrNot.java:75)
04-29 16:02:26.848: E/AndroidRuntime(530):  at exercice.thenewboston.SQLView.onCreate(SQLView.java:17)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.Activity.performCreate(Activity.java:4465)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-29 16:02:26.848: E/AndroidRuntime(530):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-29 16:02:26.848: E/AndroidRuntime(530):  ... 11 more
04-29 16:02:27.018: I/dalvikvm(530): threadid=3: reacting to signal 3
04-29 16:02:27.238: I/dalvikvm(530): Wrote stack traces to '/data/anr/traces.txt'
04-29 16:02:27.338: D/dalvikvm(530): GC_CONCURRENT freed 238K, 6% free 6678K/7047K, paused 19ms+5ms
04-29 16:02:27.388: E/SQLiteDatabase(530): close() was never explicitly called on database '/data/data/exercice.thenewboston/databases/HotOrNotdb' 
04-29 16:02:27.388: E/SQLiteDatabase(530): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1943)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1007)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:770)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at exercice.thenewboston.HotOrNot.open(HotOrNot.java:55)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at exercice.thenewboston.SQLView.onCreate(SQLView.java:16)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.Activity.performCreate(Activity.java:4465)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.os.Looper.loop(Looper.java:137)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at android.app.ActivityThread.main(ActivityThread.java:4424)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at java.lang.reflect.Method.invoke(Method.java:511)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-29 16:02:27.388: E/SQLiteDatabase(530):  at dalvik.system.NativeStart.main(Native Method)
04-29 16:02:27.527: I/dalvikvm(530): threadid=3: reacting to signal 3
04-29 16:02:27.537: I/dalvikvm(530): Wrote stack traces to '/data/anr/traces.txt'
04-29 16:02:27.837: I/dalvikvm(530): threadid=3: reacting to signal 3
04-29 16:02:27.857: I/dalvikvm(530): Wrote stack traces to '/data/anr/traces.txt'
04-29 16:02:29.787: I/Process(530): Sending signal. PID: 530 SIG: 9

I hope your help, With Regards.

More details : Answer to SAM Thanks for your reply Sam. So i put the DATABASE_VERSION = 2; and 20

@Override
public void onCreate(SQLiteDatabase db)
{
 db.execSQL("DROP TABLE IF EXITS " + DATABASE_TABLE);  // same error if i remove this line

db.execSQL("CREATE TABLE peopleTable ( _id INTEGER PRIMARY KEY AUTOINCREMENT, persons_name TEXT NOT NULL, persons_hotness TEXT NOT NULL);");
}

message error on android when i click on update "Catch. android.database.sqlite.SQLiteException:Near "EXITS":syntax error:while compiling : DROP Table if EXITS peopleTable"

04-29 19:11:50.361: W/dalvikvm(536): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-29 19:11:50.441: E/AndroidRuntime(536): FATAL EXCEPTION: main
04-29 19:11:50.441: E/AndroidRuntime(536): java.lang.RuntimeException: Unable to start activity ComponentInfo{exercice.thenewboston/exercice.thenewboston.SQLView}: android.database.sqlite.SQLiteException: near "EXITS": syntax error: , while compiling: DROP TABLE IF EXITS peopleTable
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.os.Looper.loop(Looper.java:137)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread.main(ActivityThread.java:4424)
04-29 19:11:50.441: E/AndroidRuntime(536):  at java.lang.reflect.Method.invokeNative(Native Method)
04-29 19:11:50.441: E/AndroidRuntime(536):  at java.lang.reflect.Method.invoke(Method.java:511)
04-29 19:11:50.441: E/AndroidRuntime(536):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-29 19:11:50.441: E/AndroidRuntime(536):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-29 19:11:50.441: E/AndroidRuntime(536):  at dalvik.system.NativeStart.main(Native Method)
04-29 19:11:50.441: E/AndroidRuntime(536): Caused by: android.database.sqlite.SQLiteException: near "EXITS": syntax error: , while compiling: DROP TABLE IF EXITS peopleTable
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:134)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1899)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1839)
04-29 19:11:50.441: E/AndroidRuntime(536):  at exercice.thenewboston.HotOrNot$DbHelper.onUpgrade(HotOrNot.java:44)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:170)
04-29 19:11:50.441: E/AndroidRuntime(536):  at exercice.thenewboston.HotOrNot.open(HotOrNot.java:57)
04-29 19:11:50.441: E/AndroidRuntime(536):  at exercice.thenewboston.SQLView.onCreate(SQLView.java:16)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.Activity.performCreate(Activity.java:4465)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-29 19:11:50.441: E/AndroidRuntime(536):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-29 19:11:50.441: E/AndroidRuntime(536):  ... 11 more
04-29 19:11:50.691: I/dalvikvm(536): threadid=3: reacting to signal 3
04-29 19:11:50.711: I/dalvikvm(536): Wrote stack traces to '/data/anr/traces.txt'
04-29 19:11:51.071: I/dalvikvm(536): threadid=3: reacting to signal 3
04-29 19:11:51.111: I/dalvikvm(536): Wrote stack traces to '/data/anr/traces.txt'

1 Answers1

1

Your create statement looks fine, so I would guess that have you changed you table's design at some point. Try dropping the old tables and creating the new schema. The easiest way to do this is to upgrade your DATABASE_VERSION to 2.

Sam
  • 86,580
  • 20
  • 181
  • 179
  • I have answer your on my first post (i couldn't answer here because the logs are so big for the numbers of the characters allowed on a comment. – user1364282 Apr 29 '12 at 19:22
  • If you haven't found it yet, you need to changes `EXITS` to `EXISTS`. – Sam Apr 29 '12 at 19:28
  • Thanks for the error Sam ! i haven't see it, this + the database_version and that works ! Thanks a lot :) Just a question. Is there a place for see my database without the AVD ? Look my data etc – user1364282 Apr 29 '12 at 20:06
  • 1
    Yes you can pull your database from the emulator, here is a good link: [Where does Android emulator store SQLite database?](http://stackoverflow.com/questions/1510840/where-does-android-emulator-store-sqlite-database) Read the second, more popular answer. – Sam Apr 29 '12 at 21:01
  • Nice ! The tool is very good. Thanks for the help, it's very a good forum for android developers :) – user1364282 Apr 30 '12 at 20:17