tags:

views:

47

answers:

2

Hi im trying to read sqlite file which is placed in assets/databases folder

i followed this link to read data from sqlite file http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

im getting error

no such table : while compiling SELECT _id, name, address FROM stores

Is there any permission i need to write in manifest to read sqlite file data?

Please let me know how i can solve this issue. Or else please give me any reference link to follow.

Thanks in advance

A: 

The way you'd want to do this is to make a new DBManager object that creates the database in its onCreate method--that way when the DatabaseHelper is first instantiated, the table will be created for you. Then you'd instantiate one and call getReadableDatabase() on it to get a DB object which you can then query.

This tutorial may help you more, it's more succinct and up to date: http://developer.android.com/guide/topics/data/data-storage.html#db

After that, to set up the list view in a ListActivity, you can call setListAdapter and pass in a SimpleCursorAdapter. Here's a tutorial on that: http://developer.android.com/guide/appendix/faq/commontasks.html#binding

Michael Louis Thaler
+1  A: 

Check if database already exists or not. If you are running on emulator.

write following on terminal/shell:

adb shell cd data/data/your package name(ex. com.android.etc) ls if there exists databases directory then may be database is created

cd databases ls

it will show your database if exists;

sqlite3 "your db name"

then write

.tables

it will show the name of table if exist:

now write your query over here to check for errors for ex:

sqlite> SELECT _id, name, address FROM stores

hope it helps..... and yes there are no as such required permissions for this.

viv
One thing more if database is not getting created ..... try replacing "SQLiteDatabase.openDatabase" with something like SQLiteDatabase.openOrCreateDatabase.........Hope it works
viv
Hi thanks for ur reply i tried adb shell cd .....
Praveenb