Last active
May 11, 2018 04:24
-
-
Save ryansgot/0a25a4f1c19f666ca68df74035bfc9bf to your computer and use it in GitHub Desktop.
Initializing ForSure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Android (forsuredbandroid-contentprovider) | |
package com.fsryan.forsuredb.example; | |
import android.app.Application; | |
import com.fsryan.forsuredb.FSDBHelper; | |
import com.fsryan.forsuredb.ForSureAndroidInfoFactory; | |
import com.fsryan.forsuredb.gsonserialization.FSDbInfoGsonSerializer; | |
public class App extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
if (BuildConfig.DEBUG) { | |
FSDBHelper.initDebug( // <-- initialize with logging functions enabled | |
this, | |
"testapp.db", | |
TableGenerator.generate("my.content.provider.authority.String"), | |
new FSDbInfoGsonSerializer() | |
); | |
} else { | |
FSDBHelper.init( // <-- initialize with logging functions disabled | |
this, | |
"testapp.db", | |
TableGenerator.generate("my.content.provider.authority.String"), | |
new FSDbInfoGsonSerializer() | |
); | |
} | |
ForSureAndroidInfoFactory.init(this, "my.content.provider.authority.String"); | |
ForSure.init(ForSureAndroidInfoFactory.inst()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Android (forsuredbandroid-directdb) | |
package com.fsryan.forsuredb.example; | |
import android.app.Application; | |
import com.fsryan.forsuredb.FSDBHelper; | |
import com.fsryan.forsuredb.ForSureAndroidInfoFactory; | |
import com.fsryan.forsuredb.gsonserialization.FSDbInfoGsonSerializer; | |
public class App extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
if (BuildConfig.DEBUG) { | |
FSDBHelper.initDebug(this, "testapp.db", TableGenerator.generate(), new FSDbInfoGsonSerializer()); | |
} else { | |
FSDBHelper.init(this, "testapp.db", TableGenerator.generate(), new FSDbInfoGsonSerializer()); | |
} | |
ForSure.init(ForSureAndroidInfoFactory.inst()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JDBC | |
package com.fsryan.forsuredb.example; | |
import com.fsryan.forsuredb.FSDBHelper; | |
import com.fsryan.forsuredb.ForSureJdbcInfoFactory; | |
import com.fsryan.forsuredb.gsonserialization.FSDbInfoGsonSerializer; | |
public class Main { | |
public static void main(String[] args) { | |
FSDBHelper.initDebugSQLite("jdbc:sqlite:example.db", null, TableGenerator.generate(), new FSDbInfoGsonSerializer()); | |
ForSure.init(ForSureJdbcInfoFactory.inst()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment