package com.zxcv.gonette.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class GonetteDatabaseOpenHelper extends SQLiteOpenHelper {

    private static final String TAG = "GonetteDatabaseOpenHelp";

    private static final int DATABASE_VERSION = 1;

    private static final String DATABASE_NAME = "gonette.db";

    public GonetteDatabaseOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d(TAG, "onCreate: Create table " + Tables.PARTNER);
        db.execSQL("CREATE TABLE " + Tables.PARTNER + " ("
                + PartnerColumns.ID + " INTEGER PRIMARY KEY, "
                + PartnerColumns.NAME + " TEXT NOT NULL, "
                + PartnerColumns.DESCRIPTION + " TEXT NOT NULL, "
                + PartnerColumns.LATITUDE + " INTEGER NOT NULL, "
                + PartnerColumns.LONGITUDE + " INTEGER NOT NULL "
                + ")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //TODO
    }
}

@@ -613,24 +613,323 @@
 abase db) %7B%0A
+        createDatabase(db);%0A    %7D%0A%0A    @Override%0A    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        if (newVersion %3E oldVersion) %7B%0A            dropDatabase(db);%0A            createDatabase(db);%0A        %7D%0A    %7D%0A%0A    private void createDatabase(SQLiteDatabase db) %7B%0A
         Log.
@@ -980,16 +980,16 @@
 RTNER);%0A
-
         
@@ -1398,111 +1398,182 @@
     
-@Override%0A    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) %7B%0A        //TODO
+private void dropDatabase(SQLiteDatabase db) %7B%0A        Log.d(TAG, %22dropDatabase: Drop table %22 + Tables.PARTNER);%0A        db.execSQL(%22DROP TABLE IF EXISTS %22 + Tables.PARTNER);
 %0A   

Improve database open helper