"Getting Started with Sugar ORM" for GameDevAlgorithms.com
This file contains 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.yourpackagename"> | |
| <application | |
| android:name=".MainApplication" | |
| android:icon="@mipmap/ic_launcher" | |
| android:label="@string/app_name"> | |
| <meta-data | |
| android:name="DATABASE" | |
| android:value="yourapp.db" /> | |
| <meta-data | |
| android:name="VERSION" | |
| android:value="1" /> | |
| <meta-data | |
| android:name="QUERY_LOG" | |
| android:value="false" /> | |
| <meta-data | |
| android:name="DOMAIN_PACKAGE_NAME" | |
| android:value="com.yourpackagename.model" /> | |
| </application> | |
| </manifest> |
This file contains 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
| dependencies { | |
| compile 'com.github.satyan:sugar:1.5' | |
| } |
This file contains 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
| public class MainApplication extends Application { | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| SugarContext.init(this); | |
| } | |
| @Override | |
| public void onTerminate() { | |
| super.onTerminate(); | |
| SugarContext.terminate(); | |
| } | |
| } |
This file contains 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
| @Table(name="e") | |
| public class Text extends SugarRecord { | |
| @Column(name = "a") private Long id; | |
| @Column(name = "b") private String text; | |
| public Text() {} | |
| public Text(Long id, String text) { | |
| this.id = id; | |
| this.text = text; | |
| } | |
| @Override | |
| public Long getId() { | |
| return id; | |
| } | |
| @Override | |
| public void setId(Long id) { | |
| this.id = id; | |
| } | |
| public String getText() { | |
| return text; | |
| } | |
| public void setText(String text) { | |
| this.text = text; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment