I'm new to and trying to use SQLite with ActiveAndroid ORM framework. I have a simple app and I'm following the tutorial to setup active android.
In short, I have completed followinf steps: 1. updated my Gradle setup to add repositories and compile statement. This started showing activeandroid:3.1.0-SNAPSHOT.jar file in external libraries. Also tried to copy jar file in application Lib folder as suggested on Blogs..
-
Updated AndroidManifest.xml to add android:name="com.activeandroid.app.Application" and AA_DB_NAME & AA_DB_VERSION. Also Tried to create custom class which is extended by "com.activeandroid.app.Application" and calling ActiveAndroid.initialize(this);
<application android:name="com.activeandroid.app.Application" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <meta-data android:name="AA_DB_NAME" android:value="Application.db" /> <meta-data android:name="AA_DB_VERSION" android:value="1" /> <meta-data android:name="AA_MODELS" android:value="com.digivault.pmpml.model.BusStop, com.digivault.pmpml.model.Route, com.digivault.pmpml.model.RouteStops" /> -
Created Models like following code:
@Table(name = "BusStop") public class BusStop extends Model {
@Column(name = "name", notNull = true) String name; @Column(name = "latitude") double latitude; @Column(name = "longitude") double longitude; public BusStop() { super(); } public BusStop(String name, double latitude, double longitude) { super(); this.name = name; this.latitude = latitude; this.longitude = longitude; } public BusStop(String name) { this(name, 0, 0); } public static List<BusStop> selectAll() { return new Select().from(BusStop.class).orderBy("name").execute(); } @Override public String toString() { return "BusStop{" + "name='" + name + '\'' + ", latitude=" + latitude + ", longitude=" + longitude + '}'; }}
Now for testing purpose, I have created couple of busStop objects and saved to DB.
BusStop origin = new BusStop("Katraj");
origin.save();
BusStop destination = new BusStop("Shivajinagar");
destination.save();
Later tried to retrieved the same using
BusStop bs = new BusStop();
List<BusStop> bsList = bs.selectAll();
Log.i(TAG, bs.toString());
Here I am getting empty list.
I have also tried to search Application.db in Android Device (SDCARD0/1, data/data, etc...) but not able to find the same.
I am not getting any exception on Logcat also... :(
Aucun commentaire:
Enregistrer un commentaire