// Path: DigitalOceanSwimmer/src/main/java/com/yassirh/digitalocean/utils/MyApplication.java
// public class MyApplication extends Application{
// 
//     private static Context context;
// 
//     public void onCreate(){
//         super.onCreate();
//         MyApplication.context = getApplicationContext();
//         SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
// 
//         Configuration config = getBaseContext().getResources().getConfiguration();
// 
//         String lang = settings.getString("pref_locale", "");
//         if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
//         {
//             locale = new Locale(lang);
//             Locale.setDefault(locale);
//             config.locale = locale;
//             getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
//         }
//     }
// 
//     public static Context getAppContext() {
//         return MyApplication.context;
//     }
//     
//     private Locale locale = null;
// 
//     @Override
//     public void onConfigurationChanged(Configuration newConfig)
//     {
//         super.onConfigurationChanged(newConfig);
//         if (locale != null)
//         {
//             newConfig.locale = locale;
//             Locale.setDefault(locale);
//             getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
//         }
//     }
// 
// }


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.yassirh.digitalocean.utils.MyApplication;
package com.yassirh.digitalocean.data;



public class DatabaseHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 17;
	private static final String DATABASE_NAME = "digital_ocean";
	
	private TableHelper imageTable = new ImageTable();
	private TableHelper regionTable = new RegionTable();
	private TableHelper sizeTable = new SizeTable();
	private TableHelper domainTable = new DomainTable();
	private TableHelper dropletTable = new DropletTable();
	private TableHelper recordTable = new RecordTable();
	private TableHelper sshKeyTable = new SSHKeyTable();
	private TableHelper accountTable = new AccountTable();
	private TableHelper networkTable = new NetworkTable();
	private TableHelper floatingIPTable = new FloatingIPTable();
	
	static DatabaseHelper sDatabaseHelper;
    private Context context;
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		this.context = context;
	}
	
	
	public static DatabaseHelper getInstance(Context context) {
		if (sDatabaseHelper == null) {
			sDatabaseHelper = new DatabaseHelper(context);
		}
		return sDatabaseHelper;
	}
	
	public static SQLiteDatabase getWritableDatabaseInstance() {
		if (sDatabaseHelper == null) {
// Path: DigitalOceanSwimmer/src/main/java/com/yassirh/digitalocean/utils/MyApplication.java
// public class MyApplication extends Application{
// 
//     private static Context context;
// 
//     public void onCreate(){
//         super.onCreate();
//         MyApplication.context = getApplicationContext();
//         SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
// 
//         Configuration config = getBaseContext().getResources().getConfiguration();
// 
//         String lang = settings.getString("pref_locale", "");
//         if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
//         {
//             locale = new Locale(lang);
//             Locale.setDefault(locale);
//             config.locale = locale;
//             getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
//         }
//     }
// 
//     public static Context getAppContext() {
//         return MyApplication.context;
//     }
//     
//     private Locale locale = null;
// 
//     @Override
//     public void onConfigurationChanged(Configuration newConfig)
//     {
//         super.onConfigurationChanged(newConfig);
//         if (locale != null)
//         {
//             newConfig.locale = locale;
//             Locale.setDefault(locale);
//             getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
//         }
//     }
// 
// }


// Path: DigitalOceanSwimmer/src/main/java/com/yassirh/digitalocean/data/DatabaseHelper.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.yassirh.digitalocean.utils.MyApplication;

package com.yassirh.digitalocean.data;



public class DatabaseHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 17;
	private static final String DATABASE_NAME = "digital_ocean";
	
	private TableHelper imageTable = new ImageTable();
	private TableHelper regionTable = new RegionTable();
	private TableHelper sizeTable = new SizeTable();
	private TableHelper domainTable = new DomainTable();
	private TableHelper dropletTable = new DropletTable();
	private TableHelper recordTable = new RecordTable();
	private TableHelper sshKeyTable = new SSHKeyTable();
	private TableHelper accountTable = new AccountTable();
	private TableHelper networkTable = new NetworkTable();
	private TableHelper floatingIPTable = new FloatingIPTable();
	
	static DatabaseHelper sDatabaseHelper;
    private Context context;
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		this.context = context;
	}
	
	
	public static DatabaseHelper getInstance(Context context) {
		if (sDatabaseHelper == null) {
			sDatabaseHelper = new DatabaseHelper(context);
		}
		return sDatabaseHelper;
	}
	
	public static SQLiteDatabase getWritableDatabaseInstance() {
		if (sDatabaseHelper == null) {
            sDatabaseHelper = new DatabaseHelper(MyApplication.getAppContext());