16

Possible Duplicate:
Android Sqlite - “No Such Table” Error

We are trying to develop an application on Android. We are using SQLite database and on phone we are getting

SQLiteException:no such table.

It is working fine on simulator.

Can anyone provide any input on this?

4
  • 1
    Have you run your code on a clean emulator? Have you also verified that the code that creates the table is getting executed? The next step would be to get the sqlite db off the emualtor and look at it using a sqlite database browser to check that the table does actually exist. Commented Jun 1, 2009 at 17:31
  • Hi! I have already created a database and just using the already created database's, so the table's are already created. I am just doing the SELECT on the existing table. My concern is it is working fine on simulator and not on phone Commented Jun 2, 2009 at 3:57
  • Have you verified that the table is there? It is a lot more likely that the table isn't there on the phone than select not working. Again it is very easy to verify that you DB was created correctly. Commented Jun 2, 2009 at 4:44
  • Take a look here: stackoverflow.com/questions/2342346/… Commented Nov 5, 2010 at 23:07

3 Answers 3

15

If you don't specify the database file name correctly I believe it falls back to creating an empty database. This is generally the cause of 'table not found'. Check your path and database file name.

Sign up to request clarification or add additional context in comments.

1 Comment

i was using eg : data@base-db, so db was not getting created. After i removed @ like database-db, it works for me .... :) thanks for hint...
6

I had faced a different flavour of the same problem.

I was getting no such table error when I try to insert.

Before inserting, the code was calling

mDb = mDbHelper.getWritableDatabase(); 

getWritableDatabase() , when called first time will call onCreate()

I had my SQL query to create the table within this oncreate method

public void onCreate(SQLiteDatabase db) {

            db.execSQL(DATABASE_CREATE);
            Log.v("INFO1","creating db");
            //Toast.makeText(mCtx, "created", Toast.LENGTH_SHORT).show();
        }

So for me what had happened was, the db was successfully created when the application was first run but no table due to some other errors. Later whenever the application is run, onCreate() is never called as db is already there and thus no table created, so all further SQL commands failed.

So I moved creating table out of onCreate() , and now its working

1 Comment

then how did you find db outside oncreate?
2

Some people have been able to solve the problem using the steps mentioned here. It seems to me that this problem exists on certain versions of Android 2.2. I have incorporated this change in my code, though I'm still looking for Beta testers with to see if it actually works.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.