2

When i deploy my app to Emulator in Android the DB will also get deployed. If i do any changes to DB it will not get deployed again to Emulator. To do this, everytime i have to delete the Emulator from device manager and create new one. This process is really annoying, any idea of how to delete the DB from Emulator and deploy new one.

6 Answers 6

2

you just need to increase the version of the data base which you provide in constructor or the class extending the SQLIteOpenHelper......

and override onUpgrade in SQLIteOpenHelper :

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  if (newVersion > oldVersion)
    Log.v("Database Upgrade", "Database version higher than old.");
  myContext.deleteDatabase(DB_NAME);
}
Sign up to request clarification or add additional context in comments.

Comments

1

easier:

open DDMS prespective (menu windows >> open new prespective )

select file explore tag.

then go to data > data > pakage_name> databases> data_base_name.

and delete

Comments

1

follow these steps:

DDMS > select emulater from left side panel

from right handside choose filexplorer > choose your application package click on databse foder select your database and delete it from top right handside ("red color minus") delete button

Comments

0

Quick and easy:

 context.deleteDatabase(DATABASE_NAME);

Comments

0

one more way if u want to delete database just drop table and again recreate table again as shown below where

String Droptable="drop table if exists item_master"; // where item_master is table name 
myDataBase.execSQL(Droptable); 

after dropping it recreate it as

 String Createtable="CREATE TABLE \"item_master\" (\"item_id\" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , \"item_name\" VARCHAR, \"item_img\" VARCHAR, \"item_s_desc\" TEXT, \"item_desc\" TEXT, \"item_map\" VARCHAR, \"bookmark\" VARCHAR DEFAULT N, \"category_id\" INTEGER)"; 

 myDataBase.execSQL(Createtable);

you can chnage column name or add or remove column according to ur requirement

Comments

0

Rather than deleting emulator delete the database from

ddms----> file explorer ----> data/data/your_package_name--->databases --->yourdatabase .

and delete it.

and you can do one more thing

simply uninstall the application and install it again , this will remove the database and shall create the database again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.