Skip to content

Instantly share code, notes, and snippets.

@sheerazam
Last active September 28, 2016 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheerazam/aa1df287eba7352906f5835f4667921c to your computer and use it in GitHub Desktop.
Save sheerazam/aa1df287eba7352906f5835f4667921c to your computer and use it in GitHub Desktop.
Active Android Setup
<?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>
//Add this to app level
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
@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;
}
}
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(getApplicationContext(), true);
}
}
// 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