Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORM on Android SQLite and database scheme [closed]

Tags:

I'm looking for a very simple ORM framework working on Android for SQLite. I've been testing ActiveAndroid but none of the example could ever build on Eclipse.
By the way, how do guys implement a "many to many" relationship in SQLite for Android? How do you reflect the cascade regarding deletion of rows and guarantee the database integrity?

like image 210
BlackLabrador Avatar asked Jun 04 '10 12:06

BlackLabrador


People also ask

How can I recover SQLite database in Android?

We can retrieve anything from database using an object of the Cursor class. We will call a method of this class called rawQuery and it will return a resultset with the cursor pointing to the table. We can move the cursor forward and retrieve the data. This method return the total number of columns of the table.

What is android database SQLite SQLiteDatabase?

android.database.sqlite.SQLiteDatabase. Exposes methods to manage a SQLite database. SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks.


2 Answers

I am the main author of ORMLite which has a Android backend which makes calls to the native Android OS database APIs to support its ORM functionality. We have a large number of Android developers that are using the framework successfully. See here for more information:

http://ormlite.com/sqlite_java_android_orm.shtml

In terms of many-to-many relationships, ORMLite does not support cascading or any of the more advanced ORM features but there are examples of easy many-to-many implementations:

http://ormlite.com/docs/examples

like image 121
Gray Avatar answered Sep 24 '22 10:09

Gray


For those still looking for an ORM solution, I released greenDAO some months ago. Several apps in the Android Market already use it. Unlike other Android ORM tools, one of greenDAOs primary design goals was performance. For many operations it should be multiple times faster than other solutions, e.g. it's 4-5 times faster compared to ORMLite for loading entities.

It supports relations. The documentation describes how to use relations and how you could model many-to-many relations.

Delete-cascade is a dangerous thing, and thus unsupported by greenDAO. The safer way is to delete the entities bottom-up inside a transaction.

like image 44
Markus Junginger Avatar answered Sep 24 '22 10:09

Markus Junginger