Created
March 31, 2016 22:17
-
-
Save robbiemu/35f9382ef4a07082510c8df2ca03e58d to your computer and use it in GitHub Desktop.
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 static class OldFavoritesEntry { | |
public static final Uri CONTENT_URI = | |
BASE_CONTENT_URI.buildUpon().appendPath(PATH_FAVORITES).build(); | |
public static final String CONTENT_TYPE = | |
ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_FAVORITES; | |
public static final String CONTENT_ITEM_TYPE = | |
ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_FAVORITES; | |
// Table name | |
public static final String TABLE_NAME = "favorites"; | |
// Columns | |
private static final String COLUMN_MOVIE_NAME = "name"; | |
private static final String TYPE_MOVIE_NAME = "VARCHAR(255)"; | |
private static final String COLUMN_THEMOVIEDB_ID = "idthemoviedb"; | |
private static final String TYPE_THEMOVIEDB_ID = "INTEGER"; | |
private static final String [] COLUMN_NAMES = new String[] { COLUMN_MOVIE_NAME, COLUMN_THEMOVIEDB_ID }; | |
private static final Map<String,String> COLUMN_TYPES = new HashMap<String,String> (); | |
static { | |
COLUMN_TYPES.put(COLUMN_MOVIE_NAME, TYPE_MOVIE_NAME); | |
COLUMN_TYPES.put(COLUMN_THEMOVIEDB_ID, TYPE_THEMOVIEDB_ID); | |
} | |
// Schema | |
// themoviedb's movie id is a primary key, so we don't need to recreate one. | |
// If that were no longer true, we couldn't do a query for movie details from the movie/id, so the whole API and our app would have to change. | |
public static final String SCHEMA = "favorites (" + | |
" "+COLUMN_MOVIE_NAME+" "+TYPE_MOVIE_NAME+" NOT NULL," + | |
" "+COLUMN_THEMOVIEDB_ID+" "+TYPE_THEMOVIEDB_ID+" PRIMARY KEY NOT NULL, " + | |
// ensure utf-8 encoding | |
" PRAGMA ENCODING 'utf8', " + | |
// To assure the application have just one weather entry per day | |
// per location, it's created a UNIQUE constraint with REPLACE strategy | |
" UNIQUE (" + COLUMN_MOVIE_NAME + ", " + | |
COLUMN_THEMOVIEDB_ID + ") ON CONFLICT REPLACE);"; | |
// The uri path part to be sent to themoviedb specifying the type of query. | |
public static final String COLUMN_MOVIE_SETTING = "movie"; | |
public static Uri buildLocationUri(long id) { | |
return ContentUris.withAppendedId(CONTENT_URI, id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment