Studyon Minte9.com
Android




Database



1) onCreate

This creates a file /data/myapp/comments.db
You don't have access to the /DATA/data folder on a real phone. It's chmoded 700

2) onUpdate

You can provide the onUpgrade() method and then you can execute alter table SQL see. This requires you 
to change the database version number so it can be detected when the app starts. If your schema is really 
different and you want to save the existing data then you should copy the data to a temporary table, drop 
and create the schema and copy it back again.
	
	%--- MainActivity.java

	package com.example.myapp;
	import android.app.Activity;
	import android.database.sqlite.SQLiteDatabase;
	import android.os.Bundle;

	public class MainActivity extends Activity {

	    @Override
	    protected void onCreate(Bundle state) {
			super.onCreate(state);
			setContentView(R.layout.activity_main);

                        /*--- LOOK HERE ---*/

			// Create database
			SQLiteDatabase db = new MySQLiteHelper(this).getWritableDatabase();
				// new MySQLiteHelper(this); // only create an instance	

			// Check if exists
		       String path = db.getPath().toString();
		       if(new File(path).exists()) {
			         Toast.makeText(
                                      getApplicationContext(), "Db exists", Toast.LENGTH_LONG).show();  
		        }
			// /data/data/com.example.myapp/databases/comments.db


		}
	}


	%--- MySQLiteHelper.java

	package com.example.myapp;
	import android.content.Context;
	import android.database.sqlite.SQLiteDatabase;
	import android.database.sqlite.SQLiteOpenHelper;

	public class MySQLiteHelper extends SQLiteOpenHelper {
		
		public static final String DB_NAME = "comments.db";
		public static final int DB_VERSION = 1;

		public MySQLiteHelper(Context context) {
			super(context, DB_NAME, null, DB_VERSION);
		}

		@Override
		public void onCreate(SQLiteDatabase db) {}
		
		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 
                         // db.execSQL("DROP TABLE IF EXISTS comments");
		         // onCreate(db);
                }
	}



http://www.vogella.com/articles/AndroidSQLite/article.html#databasetutorial_database
http://stackoverflow.com/questions/10888227/sqlite-database-not-created
http://stackoverflow.com/questions/10065500/android-deploy-apk-reinstall-instead-of-update