package com.usai.util;

//import android.R.array;
import java.util.ArrayList;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SqlOpenHelper extends SQLiteOpenHelper{

	private ArrayList<String> initSQL = new ArrayList<String>();
	public void addInitSQL(String sql)
	{
		initSQL.add(sql);
		
	}
	public int get_RecordCount(String tablename)
	{
		return 0;
		
	}
	public SQLiteDatabase OpenDB(boolean writable)
	{
		if (writable)
			return getWritableDatabase();
		else
			return getReadableDatabase();
	}
	
	private void initDB(SQLiteDatabase db)
	{
		for(int i=0;i<initSQL.size();i++)
		{
			db.execSQL(initSQL.get(i));
		}
	
		
	}
	public SqlOpenHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		initDB(db);
		
	}

	@Override
	public void onOpen(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		super.onOpen(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}

}
