package com.ethostream.ethoandroid;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


/**
 * @author Matt Boelter - mboelter@ethostream.com
 * 
 * This class should act as the main database helper. Currently it is only a
 * skeleton class.
 * 
 * TODO: Implement essential database functions here, and have the adapters
 * function through this class. Do this to ensure the database does not get 
 * locked and limit conflicts.
 * 
 * TODO: At least ensure that the database is using the desired path, if opened
 * in an adapter class.
 *
 */
public class LocalSQLiteHelper extends SQLiteOpenHelper {

	private static final String DB_PATH = "/data/data/com.ethostream.ethoandroid/databases/";
	private static final String DB_NAME = "localcache.db";

	/**
	 * Constructor
	 * 
	 * @param context
	 */
	public LocalSQLiteHelper(Context context) 
	{
		super(context, DB_NAME, null, 1);
	}
	

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
	 */
	public void onCreate(SQLiteDatabase db) 
	{

	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
	 */
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
	{
		// Not concerned with upgrading schemas
	}

	/**
	 * Commands to open/create a database. Not called currently, since the adapter
	 * is over-stepping its responsibility.
	 */
	public void createDatabase() 
	{
		Log.i(this.toString(), "CREATE DATABASE=========================================");
		SQLiteDatabase db;
		db = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, SQLiteDatabase.CREATE_IF_NECESSARY);
		db.close();
	}

}
