2

Title-Android-read database in raw folder..

My raw folder contains a database 'abc' & abc database contains one table say- xyz i want to open 'abc' database for fetching data in it..

i want to use something like

SQLiteDatabase db=SQLiteDatabase.openDatabase(path, factory, flags);

1) how to give path to access database?

2) i want to open table & perform operation Cursor c=db.query("xyz",null,null,null,null,null);

Adnan Maqbool
  • 452
  • 3
  • 10
user1461473
  • 41
  • 2
  • 8

2 Answers2

0

Raw has no path: It is a resource, so you need to reference is as such using getResources().

You should, at the first run, copy it to the /data/data/YOUR_APP_FOLDER/databases/YOUR_DB.db

Follow this tutorial.

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Chirag
  • 56,621
  • 29
  • 151
  • 198
0

Copy your database file from /res/raw or /asset in /data/data/<application_package_name>/database/ directory and give path of that directory.

Now you can easily access your database file from /data/data//database/ directory..

Look at Ship an application with a database

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151
  • 1
    its true but i want to access database from only raw or asset folder without changing its location.. is it possible??? – user1461473 Jun 22 '12 at 13:36