Reputation: 1647
I've started Android programming recently so bear with me :)
I develop an app which has all of its content stored in database.sql file. I've implemented a subclass of SQLiteOpenHelper and added database.sql to my project assets.
public class DBHelper extends SQLiteOpenHelper
{
public DBHelper (Context ctx)
{
super(ctx, "database.sql", null, 1);
}
}
This thing doesn't work. I just get an exception every time I try to do smth with DB :(
Upvotes: 2
Views: 6658
Reputation: 196
You have 3 choices when you want to create a database locally in Android; hopefully they will support deployment directly from the APK soon. The database needs to be in a specific location :
/data/data/YOUR_PACKAGE/databases/
Also see http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Upvotes: 4