0

I get a runtime error with this code. Whats my mistake?

String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
Cursor cur = myDataBase.rawQuery("SELECT * FROM  personel" , null);    
cur.moveToFirst();
cur.close();
myDataBase.close();

this is my logcat:

this is my logcat:

03-06 14:35:14.821: E/AndroidRuntime(11995): FATAL EXCEPTION: main
03-06 14:35:14.821: E/AndroidRuntime(11995): java.lang.RuntimeException: Unable to start activity ComponentInfo{Dic.proj.pkg/Dic.proj.pkg.DictionaryActivity}: android.database.sqlite.SQLiteException: no such table: personel: , while compiling: Select * from personel
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.os.Looper.loop(Looper.java:123)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread.main(ActivityThread.java:3683)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at java.lang.reflect.Method.invoke(Method.java:507)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at dalvik.system.NativeStart.main(Native Method)
03-06 14:35:14.821: E/AndroidRuntime(11995): Caused by: android.database.sqlite.SQLiteException: no such table: personel: , while compiling: Select * from personel
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at Dic.proj.pkg.DataBaseHelper.getCount(DataBaseHelper.java:126)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at Dic.proj.pkg.DictionaryActivity.onCreate(DictionaryActivity.java:44)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 14:35:14.821: E/AndroidRuntime(11995):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
9
  • 3
    What error are you getting? Commented Mar 6, 2012 at 9:29
  • 2
    post the error log... the picture is too vague. Commented Mar 6, 2012 at 9:32
  • when i run my program i don't get any error in Error Log. but in emulator i get this error: The Application App_name has stopped unexpectedly. please try again Commented Mar 6, 2012 at 9:39
  • Debug it and find where the error starts? Commented Mar 6, 2012 at 9:45
  • 1
    Verify that you created the table first and it may be a spelling mistake in personel, because the correct spell is personnel. double check that your table (if already created, its) name is also the same as you using in query. Commented Mar 6, 2012 at 11:24

1 Answer 1

1

You may have included the "personel" table recently & not upgraded the database version OR you may have changed the defenition of "personel" so try to increase the DataBase-Version here:

public DatabaseHelper(Context context) 
{
    super(context, dbName, null,Increment the value here);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.