Last active
September 28, 2016 13:31
-
-
Save sheerazam/aa1df287eba7352906f5835f4667921c to your computer and use it in GitHub Desktop.
Active Android Setup
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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="retaillogics.activeandroidsample"> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme" | |
android:name=".MyApplication" | |
> | |
<activity android:name=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<!-- add the following metadata for version and database name --> | |
<meta-data | |
android:name="AA_DB_NAME" | |
android:value="RestClient.db" /> | |
<meta-data | |
android:name="AA_DB_VERSION" | |
android:value="1" /> | |
<meta-data | |
android:name="AA_MODELS" | |
android:value="retaillogics.activeandroidsample.Item" /> | |
</application> | |
</manifest> |
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
//Add this to app level | |
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' |
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
@Table(name = "Items") | |
public class Item extends Model { | |
@Column(name = "remote_id", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE) | |
public long remoteId; | |
@Column(name = "Name") | |
public String name; | |
// Make sure to have a default constructor for every ActiveAndroid model | |
public Item(){ | |
super(); | |
} | |
public Item(int remoteId, String name){ | |
super(); | |
this.remoteId = remoteId; | |
this.name = name; | |
} | |
} |
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
public class MyApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
ActiveAndroid.initialize(getApplicationContext(), true); | |
} | |
} |
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
// add this to top level gradle file | |
allprojects { | |
repositories { | |
jcenter() | |
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment