11

I open a sqlite database and use rawquery to get data.

But the log.e show the information:

android.database.sqlite.SQLiteException: no such table: types:

But, I really have this table.

And i also try to use the other sql ,But also get the error message such as

android.database.sqlite.SQLiteException: no such table: malls:

I am sure there are this two tables. So why get the error message?

6
  • hey there, what does the rawquery look like? are the table names "types:" and "malls:" ? Commented Feb 26, 2010 at 14:45
  • Do you really create your database with CREATE TABLE... ? Commented Feb 26, 2010 at 14:46
  • Actually, i already have a database file. So i just put it in the "assets" folder. And i crate a custom SQLiteOpenHelper to copy this file to path : /data/data/com.SGMalls/databases/mallMapv2.sqlite Then to use Sqlitedatabse.open(); to open this database and try to get data Commented Feb 26, 2010 at 15:00
  • The rawquery Cursor cursor=myDataBase.rawQuery(queryString, null); And i have test this queryString in Sqlitebrowser. It's ok. Can get the data Commented Feb 26, 2010 at 15:04
  • This database is large. So this is the problem? Because i write the custom SQLiteOpenHelper from "Using your own SQLite database in Android applications" reigndesign.com/blog/… So the copy file code may be can not copy the complete file. Yes? Commented Feb 26, 2010 at 15:15

4 Answers 4

11

If this is on the emulator, use DDMS File Explorer or adb pull to download a copy of the database file and confirm its contents.

And i crate a custom SQLiteOpenHelper to copy this file to path : /data/data/com.SGMalls/databases/mallMapv2.sqlite

If you are attempting to copy the file in SQLiteOpenHelper's onCreate(), you are too late. I would do it before then.

So the copy file code may be can not copy the complete file.

It is more likely you would get an error about a corrupt file in that case.

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

4 Comments

OK. thanks very much. So. if i want to test this code in device. Also need paste the sqlite database in the device first? O...i need to read a tutorial carefully Thanks
Hi.As you said: I use to ddms file explorer to pull the database file. And i find there are three floder : data,sdcared and system. So any one is ok? and the path of this file also is /data/data/com.SGMalls/databases/mallMapv2.sqlite? Thanks. Pls help me
>>>>If you are attempting to copy the file in SQLiteOpenHelper's onCreate(), you are too late. I would do it before then.<<<<<< THAT WORKED FOR ME THANKS... +1
@CommonsWare : In my android phone there is not path like data/data. Can that be the reason "table not found error". Because data/data is not present in my phone, is not able to copy my database from the assets folder into data/data/com.myapp/databases. Is this the problem?
2

I think this error occurs when you change the table structure. To solve this, clean the data (Settings -> Manage application -> Clear data) before installing the new application.

Regards.

Comments

2

If you have multiple contents providers, you might think that your table exists while it does not. In which case the error you are getting is legitimate.

Take a look here for details and solution: http://devserghini.blogspot.com/2010/11/android-sqliteopenhelper-and-multiple.html

Comments

1

SQLiteDatabase.execSQL() interpretation takes a single string sql, ending with ";". Two lines have not interpreted.

Creating tables in a few lines sql just not executed.

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.