Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Last active December 30, 2015 06:29
Show Gist options
  • Save shikajiro/7789950 to your computer and use it in GitHub Desktop.
Save shikajiro/7789950 to your computer and use it in GitHub Desktop.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.hoge"
android:versionCode="1"
android:versionName="1.0" >
<application
android:name=".AppImpl_"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>
@EApplication
public class AppImpl extends Application {
private DatabaseHelper dbHelper;
@Override
public void onCreate() {
super.onCreate();
DeployGate.install(this);
createDB();
// springでのhttpアクセスで必須の設定
System.setProperty("http.keepAlive", "false");
}
public void createDB() {
this.dbHelper = new DatabaseHelper(this, null);
}
public void closeDB() {
if (dbHelper != null) {
dbHelper.close();
}
}
public DaoSession getDaoSession() {
return this.dbHelper.getDaoSession();
}
}
@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {
@App AppImpl app;
@AfterViews
void onAfterViews(){
ItemDao dao = app.getDaoSession().getItemDao();
//hogehoge
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment