Commit 771e09c9 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix sql trigger creation

parent 081955c1
...@@ -42,7 +42,6 @@ import android.database.sqlite.SQLiteFullException; ...@@ -42,7 +42,6 @@ import android.database.sqlite.SQLiteFullException;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.Log; import android.util.Log;
public class MediaDatabase { public class MediaDatabase {
...@@ -207,14 +206,11 @@ public class MediaDatabase { ...@@ -207,14 +206,11 @@ public class MediaDatabase {
MRL_URI + " TEXT PRIMARY KEY NOT NULL,"+ MRL_URI + " TEXT PRIMARY KEY NOT NULL,"+
MRL_DATE + " DATETIME NOT NULL" MRL_DATE + " DATETIME NOT NULL"
+");"; +");";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && createMrlTableQuery += " CREATE TRIGGER mrl_history_trigger AFTER INSERT ON "+
Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2) { MRL_TABLE_NAME+ " BEGIN "+
createMrlTableQuery += "CREATE TRIGGER mrl_history_trigger AFTER INSERT ON " + " DELETE FROM "+MRL_TABLE_NAME+" where "+MRL_URI+" NOT IN (SELECT "+MRL_URI+
MRL_TABLE_NAME + "BEGIN " + " from "+MRL_TABLE_NAME+" ORDER BY insertion_date DESC LIMIT "+MRL_TABLE_SIZE+");"+
"DELETE FROM " + MRL_TABLE_NAME + " where " + MRL_URI + " NOT IN (SELECT " + MRL_URI + " END";
" from " + MRL_TABLE_NAME + " ORDER BY insertion_date DESC LIMIT " + MRL_TABLE_SIZE + ")" +
"END";
}
db.execSQL(createMrlTableQuery); db.execSQL(createMrlTableQuery);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment