I’m basically developing a basic android-sqlite-database app. I have successfully run it. It gets “name” and “Phone number” and adds to the database at “data/data/com.android.databaseapp” Now I want to put the database into the app, I have followed the tutorials but not succeeded. Please give me some detailed directions here I have added the .db file in assets and followed 2 toturials for this but assets/.db file does not gets update. only “data/data/com.android.databaseapp/.db” file gets update My DatabaseHadler class is:
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "contactsManager";
private static final String TABLE_CONTACTS = "contacts";
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_PH_NO = "phone_number";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT,"
+ KEY_PH_NO + " TEXT" + ")";
db.execSQL(CREATE_CONTACTS_TABLE);
db.close();
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
// Create tables again
onCreate(db);
db.close();
}
Plzzz guide me here.....