Created
October 13, 2013 03:53
-
-
Save tacck/6957978 to your computer and use it in GitHub Desktop.
AndroidでSQLiteはどこまで書くものか ref: http://qiita.com/tacck/items/6ef046cbbf1d848cfeea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CodeSampleData extends SampleData { | |
public static final String CREATE_TABLE = "" | |
+ "create table " + TABLE_NAME + " ( " | |
+ FIELD_ID + " integer primary key autoincrement " | |
+ ", " + FIELD_VALUE_INT + " integer " | |
+ ", " + FIELD_VALUE_LONG + " integer " | |
+ ", " + FIELD_VALUE_BOOL + " integer " | |
+ ", " + FIELD_VALUE_STRING_8 + " text " | |
+ ", " + FIELD_VALUE_STRING_100 + " text " | |
+ ", " + FIELD_VALUE_STRING_1000 + " text " | |
+ ", " + FIELD_VALUE_STRING_LT_100 + " text " | |
+ " );"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleData { | |
public static final String TABLE_NAME = "tab"; | |
public static final String FIELD_ID = "id"; | |
public static final String FIELD_VALUE_INT = "VALUE_INT"; | |
public static final String FIELD_VALUE_LONG = "VALUE_LONG"; | |
public static final String FIELD_VALUE_BOOL = "VALUE_BOOL"; | |
public static final String FIELD_VALUE_STRING_8 = "STRING_8"; | |
public static final String FIELD_VALUE_STRING_100 = "STRING_100"; | |
public static final String FIELD_VALUE_STRING_1000 = "STRING_1000"; | |
public static final String FIELD_VALUE_STRING_LT_100 = "STRING_LT_100"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SqlSampleData extends SampleData { | |
public static final String CREATE_TABLE = "" | |
+ "create table " + TABLE_NAME + " ( " | |
+ FIELD_ID + " integer primary key autoincrement " | |
+ ", " + FIELD_VALUE_INT + " integer " | |
+ ", " + FIELD_VALUE_LONG + " integer " | |
+ ", " + FIELD_VALUE_BOOL + " integer " + "check(" + FIELD_VALUE_BOOL + " IN (0, 1)) " | |
+ ", " + FIELD_VALUE_STRING_8 + " text " + "check(length(" + FIELD_VALUE_STRING_8 + ") = 8)" | |
+ ", " + FIELD_VALUE_STRING_100 + " text " + "check(length(" + FIELD_VALUE_STRING_100 + ") = 100)" | |
+ ", " + FIELD_VALUE_STRING_1000 + " text " + "check(length(" + FIELD_VALUE_STRING_1000 + ") = 1000)" | |
+ ", " + FIELD_VALUE_STRING_LT_100 + " text " + "check(length(" + FIELD_VALUE_STRING_LT_100 + ") < 100)" | |
+ " );"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment