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;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.Log;
public class MediaDatabase {
......@@ -207,14 +206,11 @@ public class MediaDatabase {
MRL_URI + " TEXT PRIMARY KEY NOT NULL,"+
MRL_DATE + " DATETIME NOT NULL"
+");";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB &&
Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2) {
createMrlTableQuery += "CREATE TRIGGER mrl_history_trigger AFTER INSERT ON " +
MRL_TABLE_NAME + "BEGIN " +
"DELETE FROM " + MRL_TABLE_NAME + " where " + MRL_URI + " NOT IN (SELECT " + MRL_URI +
" from " + MRL_TABLE_NAME + " ORDER BY insertion_date DESC LIMIT " + MRL_TABLE_SIZE + ")" +
"END";
}
createMrlTableQuery += " CREATE TRIGGER mrl_history_trigger AFTER INSERT ON "+
MRL_TABLE_NAME+ " BEGIN "+
" DELETE FROM "+MRL_TABLE_NAME+" where "+MRL_URI+" NOT IN (SELECT "+MRL_URI+
" from "+MRL_TABLE_NAME+" ORDER BY insertion_date DESC LIMIT "+MRL_TABLE_SIZE+");"+
" END";
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