package com.corneliudascalu.mvpnotes.data.model;

import com.corneliudascalu.mvpnotes.AppModule;
import com.corneliudascalu.mvpnotes.MVPNotesApp;
import com.corneliudascalu.mvpnotes.data.interactor.impl.NoteInteractorImpl;

import android.content.Context;
import android.content.SharedPreferences;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * @author Corneliu Dascalu <corneliu.dascalu@gmail.com>
 */
@Module(injects = NoteInteractorImpl.class, addsTo = AppModule.class)
public class DatabaseModule {

    @Provides
    @Singleton
    public SimpleDatabase provideSimpleDatabase(MVPNotesApp app) {
        SharedPreferences sharedPreferences = app
                .getSharedPreferences("notes_db", Context.MODE_PRIVATE);
        return new SimpleDatabase(sharedPreferences);
    }
}

@@ -375,16 +375,141 @@
 s;%0A%0A/**%0A
+ * A module that provides a SimpleDatabase instance. It adds to AppModule to %0A * get the MVPNotesApp instance from there%0A * %0A
  * @auth

Comment for DatabaseModule