2011-04-20 12:10:34 -04:00
|
|
|
package hu.blint.ssldroid.db;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
|
import android.database.sqlite.SQLiteOpenHelper;
|
2011-10-19 05:44:43 -04:00
|
|
|
import android.util.Log;
|
2011-04-20 12:10:34 -04:00
|
|
|
|
|
|
|
public class SSLDroidDbHelper extends SQLiteOpenHelper {
|
2011-05-04 15:31:26 -04:00
|
|
|
private static final String DATABASE_NAME = "applicationdata";
|
2011-10-19 05:44:43 -04:00
|
|
|
private static final int DATABASE_VERSION = 2;
|
2011-05-04 15:31:26 -04:00
|
|
|
|
|
|
|
// Database creation sql statement
|
2011-10-19 05:44:43 -04:00
|
|
|
private static final String DATABASE_CREATE = "CREATE TABLE IF NOT EXISTS tunnels (_id integer primary key autoincrement, "
|
2011-05-04 15:31:26 -04:00
|
|
|
+ "name text not null, localport integer not null, remotehost text not null, "
|
|
|
|
+ "remoteport integer not null, pkcsfile text not null, pkcspass text );";
|
2011-10-19 05:44:43 -04:00
|
|
|
private static final String STATUS_CREATE = "CREATE TABLE IF NOT EXISTS status (name text, value text);";
|
2011-05-04 15:31:26 -04:00
|
|
|
|
|
|
|
public SSLDroidDbHelper(Context context) {
|
|
|
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Method is called during creation of the database
|
|
|
|
@Override
|
|
|
|
public void onCreate(SQLiteDatabase database) {
|
|
|
|
database.execSQL(DATABASE_CREATE);
|
2011-10-19 05:44:43 -04:00
|
|
|
database.execSQL(STATUS_CREATE);
|
2011-05-04 15:31:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Method is called during an update of the database, e.g. if you increase
|
|
|
|
// the database version
|
|
|
|
@Override
|
|
|
|
public void onUpgrade(SQLiteDatabase database, int oldVersion,
|
|
|
|
int newVersion) {
|
2011-10-19 05:44:43 -04:00
|
|
|
Log.w(SSLDroidDbHelper.class.getName(),
|
2011-05-04 15:31:26 -04:00
|
|
|
"Upgrading database from version " + oldVersion + " to "
|
2011-10-19 05:44:43 -04:00
|
|
|
+ newVersion + ", which will add a status table");
|
|
|
|
database.execSQL("CREATE TABLE IF NOT EXISTS status (name text, value text);");
|
|
|
|
onCreate(database);
|
2011-05-04 15:31:26 -04:00
|
|
|
}
|
2011-04-20 12:10:34 -04:00
|
|
|
}
|
|
|
|
|