package app.android.simpleflashcards.models;


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


public class DatabaseProvider
{
	public class AlreadyInstantiatedException extends RuntimeException
	{
	}

	private static DatabaseProvider instance = null;
	private SimpleFlashcardsOpenHelper openHelper;
	private Decks decks = null;
	private LastUpdateTimeHandler lastUpdateTimeHandler = null;

	public static DatabaseProvider getInstance() {
		return instance;
	}

	public static DatabaseProvider getInstance(Context context) {
		if (instance == null) {
			return new DatabaseProvider(context);
		}
		else {
			return instance;
		}
	}

	private DatabaseProvider(Context context) {
		if (instance != null) {
			throw new AlreadyInstantiatedException();
		}

		openHelper = new SimpleFlashcardsOpenHelper(context.getApplicationContext());

		instance = this;
	}

	public Decks getDecks() {
		if (decks == null) {
			decks = new Decks();
		}
		return decks;
	}

	LastUpdateTimeHandler getLastUpdateTimeHandler() {
		if (lastUpdateTimeHandler == null) {
			lastUpdateTimeHandler = new LastUpdateTimeHandler();
		}
		return lastUpdateTimeHandler;
	}

	SQLiteDatabase getDatabase() {
		return openHelper.getWritableDatabase();
	}
}

@@ -269,25 +269,18 @@
 instance
- = null
 ;%0A
+
 %09private
@@ -339,23 +339,16 @@
 ks decks
- = null
 ;%0A%09priva
@@ -397,15 +397,8 @@
 dler
- = null
 ;%0A%0A%09

Remove needless DatabaseProvider fields initialization to null.