I think I have some basic understanding problem so maybe someone\'s able to help :-)
I\'m developing an Android application using Eclipse and this application will m
In a comment to this answer, CommonsWare recommends against the same method proposed by @evilone here (ie, copying the database from assets yourself). Instead you should use the tried and tested SQLiteAssetHelper. I've used it in Android Studio and it works well.
The directions are fairly clear. Here are a few key excerpts:
If you are using the Gradle build system, simply add the following dependency in your
build.gradlefile:
dependencies {
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
}
Extend
SQLiteAssetHelperas you would normally doSQLiteOpenHelper, providing the constructor with a database name and version number:
public class MyDatabase extends SQLiteAssetHelper {
private static final String DATABASE_NAME = "northwind.db";
private static final int DATABASE_VERSION = 1;
public MyDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
}
Put your database in assets/databases/northwind.db (using whatever database name you have).
The database is made available for use the first time either
getReadableDatabase()orgetWritableDatabase()is called.