Refactored create table statements to use constants from schema.

This commit is contained in:
Peter Serwylo 2016-06-30 16:58:41 +10:00
parent 2ffd4ae428
commit 131978ad02

View File

@ -24,74 +24,81 @@ class DBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "fdroid";
private static final String CREATE_TABLE_REPO = "create table "
+ RepoTable.NAME + " (_id integer primary key, "
+ "address text not null, "
+ "name text, description text, inuse integer not null, "
+ "priority integer not null, pubkey text, fingerprint text, "
+ "maxage integer not null default 0, "
+ "version integer not null default 0, "
+ "lastetag text, lastUpdated string,"
+ "isSwap integer boolean default 0,"
+ "username string, password string,"
+ "timestamp integer not null default 0"
+ RepoTable.NAME + " ("
+ RepoTable.Cols._ID + " integer primary key, "
+ RepoTable.Cols.ADDRESS + " text not null, "
+ RepoTable.Cols.NAME + " text, "
+ RepoTable.Cols.DESCRIPTION + " text, "
+ RepoTable.Cols.IN_USE + " integer not null, "
+ RepoTable.Cols.PRIORITY + " integer not null, "
+ RepoTable.Cols.SIGNING_CERT + " text, "
+ RepoTable.Cols.FINGERPRINT + " text, "
+ RepoTable.Cols.MAX_AGE + " integer not null default 0, "
+ RepoTable.Cols.VERSION + " integer not null default 0, "
+ RepoTable.Cols.LAST_ETAG + " text, "
+ RepoTable.Cols.LAST_UPDATED + " string,"
+ RepoTable.Cols.IS_SWAP + " integer boolean default 0,"
+ RepoTable.Cols.USERNAME + " string, "
+ RepoTable.Cols.PASSWORD + " string,"
+ RepoTable.Cols.TIMESTAMP + " integer not null default 0"
+ ");";
private static final String CREATE_TABLE_APK =
"CREATE TABLE " + ApkTable.NAME + " ( "
+ "id text not null, "
+ "version text not null, "
+ "repo integer not null, "
+ "hash text not null, "
+ "vercode int not null,"
+ "apkName text not null, "
+ "size int not null, "
+ "sig string, "
+ "srcname string, "
+ "minSdkVersion integer, "
+ "targetSdkVersion integer, "
+ "maxSdkVersion integer, "
+ "permissions string, "
+ "features string, "
+ "nativecode string, "
+ "hashType string, "
+ "added string, "
+ "compatible int not null, "
+ "incompatibleReasons text, "
+ "primary key(id, vercode)"
+ ApkTable.Cols.PACKAGE_NAME + " text not null, "
+ ApkTable.Cols.VERSION_NAME + " text not null, "
+ ApkTable.Cols.REPO_ID + " integer not null, "
+ ApkTable.Cols.HASH + " text not null, "
+ ApkTable.Cols.VERSION_CODE + " int not null,"
+ ApkTable.Cols.NAME + " text not null, "
+ ApkTable.Cols.SIZE + " int not null, "
+ ApkTable.Cols.SIGNATURE + " string, "
+ ApkTable.Cols.SOURCE_NAME + " string, "
+ ApkTable.Cols.MIN_SDK_VERSION + " integer, "
+ ApkTable.Cols.TARGET_SDK_VERSION + " integer, "
+ ApkTable.Cols.MAX_SDK_VERSION + " integer, "
+ ApkTable.Cols.PERMISSIONS + " string, "
+ ApkTable.Cols.FEATURES + " string, "
+ ApkTable.Cols.NATIVE_CODE + " string, "
+ ApkTable.Cols.HASH_TYPE + " string, "
+ ApkTable.Cols.ADDED_DATE + " string, "
+ ApkTable.Cols.IS_COMPATIBLE + " int not null, "
+ ApkTable.Cols.INCOMPATIBLE_REASONS + " text, "
+ "primary key(" + ApkTable.Cols.PACKAGE_NAME + ", " + ApkTable.Cols.VERSION_CODE + ")"
+ ");";
private static final String CREATE_TABLE_APP = "CREATE TABLE " + AppTable.NAME
+ " ( "
+ "id text not null, "
+ "name text not null, "
+ "summary text not null, "
+ "icon text, "
+ "description text not null, "
+ "license text not null, "
+ "author text, "
+ "email text, "
+ "webURL text, "
+ "trackerURL text, "
+ "sourceURL text, "
+ "changelogURL text, "
+ "suggestedVercode text,"
+ "upstreamVersion text,"
+ "upstreamVercode integer,"
+ "antiFeatures string,"
+ "donateURL string,"
+ "bitcoinAddr string,"
+ "litecoinAddr string,"
+ "flattrID string,"
+ "requirements string,"
+ "categories string,"
+ "added string,"
+ "lastUpdated string,"
+ "compatible int not null,"
+ "ignoreAllUpdates int not null,"
+ "ignoreThisUpdate int not null,"
+ "iconUrl text, "
+ "iconUrlLarge text, "
+ "primary key(id));";
+ AppTable.Cols.PACKAGE_NAME + "id text not null, "
+ AppTable.Cols.NAME + "name text not null, "
+ AppTable.Cols.SUMMARY + "summary text not null, "
+ AppTable.Cols.ICON + "icon text, "
+ AppTable.Cols.DESCRIPTION + "description text not null, "
+ AppTable.Cols.LICENSE + "license text not null, "
+ AppTable.Cols.AUTHOR + "author text, "
+ AppTable.Cols.EMAIL + "email text, "
+ AppTable.Cols.WEB_URL + "webURL text, "
+ AppTable.Cols.TRACKER_URL + "trackerURL text, "
+ AppTable.Cols.SOURCE_URL + "sourceURL text, "
+ AppTable.Cols.CHANGELOG_URL + "changelogURL text, "
+ AppTable.Cols.SUGGESTED_VERSION_CODE + "suggestedVercode text,"
+ AppTable.Cols.UPSTREAM_VERSION_NAME + "upstreamVersion text,"
+ AppTable.Cols.UPSTREAM_VERSION_CODE + "upstreamVercode integer,"
+ AppTable.Cols.ANTI_FEATURES + "antiFeatures string,"
+ AppTable.Cols.DONATE_URL + "donateURL string,"
+ AppTable.Cols.BITCOIN_ADDR + "bitcoinAddr string,"
+ AppTable.Cols.LITECOIN_ADDR + "litecoinAddr string,"
+ AppTable.Cols.FLATTR_ID + "flattrID string,"
+ AppTable.Cols.REQUIREMENTS + "requirements string,"
+ AppTable.Cols.CATEGORIES + "categories string,"
+ AppTable.Cols.ADDED + "added string,"
+ AppTable.Cols.LAST_UPDATED + "lastUpdated string,"
+ AppTable.Cols.IS_COMPATIBLE + "compatible int not null,"
+ AppTable.Cols.IGNORE_ALLUPDATES + "ignoreAllUpdates int not null,"
+ AppTable.Cols.IGNORE_THISUPDATE + "ignoreThisUpdate int not null,"
+ AppTable.Cols.ICON_URL + "iconUrl text, "
+ AppTable.Cols.ICON_URL_LARGE + "iconUrlLarge text, "
+ "primary key(" + AppTable.Cols.PACKAGE_NAME + "));";
private static final String CREATE_TABLE_INSTALLED_APP = "CREATE TABLE " + InstalledAppTable.NAME
+ " ( "