summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/common
diff options
context:
space:
mode:
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/common')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/Entry.java2
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/EntrySchema.java17
2 files changed, 17 insertions, 2 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/Entry.java b/gallerycommon/src/com/android/gallery3d/common/Entry.java
index b8cc51205..3f1644e65 100644
--- a/gallerycommon/src/com/android/gallery3d/common/Entry.java
+++ b/gallerycommon/src/com/android/gallery3d/common/Entry.java
@@ -48,6 +48,8 @@ public abstract class Entry {
boolean fullText() default false;
String defaultValue() default "";
+
+ boolean unique() default false;
}
public void clear() {
diff --git a/gallerycommon/src/com/android/gallery3d/common/EntrySchema.java b/gallerycommon/src/com/android/gallery3d/common/EntrySchema.java
index 46de03fd6..7bf7e431c 100644
--- a/gallerycommon/src/com/android/gallery3d/common/EntrySchema.java
+++ b/gallerycommon/src/com/android/gallery3d/common/EntrySchema.java
@@ -300,6 +300,7 @@ public final class EntrySchema {
StringBuilder sql = new StringBuilder("CREATE TABLE ");
sql.append(tableName);
sql.append(" (_id INTEGER PRIMARY KEY AUTOINCREMENT");
+ StringBuilder unique = new StringBuilder();
for (ColumnInfo column : mColumnInfo) {
if (!column.isId()) {
sql.append(',');
@@ -310,8 +311,18 @@ public final class EntrySchema {
sql.append(" DEFAULT ");
sql.append(column.defaultValue);
}
+ if (column.unique) {
+ if (unique.length() == 0) {
+ unique.append(column.name);
+ } else {
+ unique.append(',').append(column.name);
+ }
+ }
}
}
+ if (unique.length() > 0) {
+ sql.append(",UNIQUE(").append(unique).append(')');
+ }
sql.append(");");
logExecSql(db, sql.toString());
sql.setLength(0);
@@ -493,7 +504,7 @@ public final class EntrySchema {
// Add the column to the array.
int index = columns.size();
- columns.add(new ColumnInfo(info.value(), type, info.indexed(),
+ columns.add(new ColumnInfo(info.value(), type, info.indexed(), info.unique(),
info.fullText(), info.defaultValue(), field, index));
}
}
@@ -504,16 +515,18 @@ public final class EntrySchema {
public final String name;
public final int type;
public final boolean indexed;
+ public final boolean unique;
public final boolean fullText;
public final String defaultValue;
public final Field field;
public final int projectionIndex;
- public ColumnInfo(String name, int type, boolean indexed,
+ public ColumnInfo(String name, int type, boolean indexed, boolean unique,
boolean fullText, String defaultValue, Field field, int projectionIndex) {
this.name = name.toLowerCase();
this.type = type;
this.indexed = indexed;
+ this.unique = unique;
this.fullText = fullText;
this.defaultValue = defaultValue;
this.field = field;