0

Im clueless.

I've got this statement saying:

contactDBHelper.addText("HI!");

in an AlertDialog

when I run this in the emulator and click save I can see it appering in the database, however, when I try to test it on my phone I get this message:

E/SQLiteLog(18458): (1) no such table: text_table
E/SQLiteDatabase(18458): Error inserting txt=HEI!
E/SQLiteDatabase(18458): android.database.sqlite.SQLiteException: no such table: text_table 
(code 1): , while compiling: INSERT INTO text_table(txt) VALUES (?)
E/SQLiteDatabase(18458): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)

Why is this happening? isnt the emulator suppose to work just like the phone?

The Dude
  • 1,088
  • 7
  • 16
  • 30
  • http://stackoverflow.com/questions/21881992/when-is-sqliteopenhelper-oncreate-onupgrade-run – laalto Oct 24 '14 at 10:42
  • The table is not created when you are testing on phone, while it was already created earlier on the emulator. It might be related to your code, specifically the classes you extended to use with DB, please post additional info related to that code. – Cornel Oct 24 '14 at 10:44

1 Answers1

1

try changing the version of database and then running it on phone. also post your SQLiteOpenHelper class code.

Hirak Chhatbar
  • 3,159
  • 1
  • 27
  • 36
  • It worked setting the Version from 1 to 2. Does this mean that from now on I have to use version 2, and if I for some reason should have to set it to 3, thats the version I have to use from thenon – The Dude Oct 24 '14 at 10:44
  • 1
    yupp..exactly.. i am develoing an app and I am at version 39 :p If u want to use the same version again but still want to refresh the data inside it, temperorily create a delete button that deletes the entire database. – Hirak Chhatbar Oct 24 '14 at 10:46