<commit_before>package net.leifandersen.mobile.android.netcatch.providers;

import java.util.List;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;

/**
 * Manages the content provider for all show data.
 * 
 * @author <NAME>
 *
 */
public class ShowsProvider extends ContentProvider {

	/**
	 * The provider name for shows subscriptions and episodes.
	 */
	public static final String PROVIDER_NAME = 
		"net.leifandersen.provider.Shows";

	/**
	 * The Subscriptions URI.
	 */
	public static final Uri SUBSCRIPCTIONS_CONTENT_URI = 
		Uri.parse("content://" + PROVIDER_NAME + "/subscriptions");

	/**
	 * The queue URI
	 */
	public static final Uri QUEUE_CONTENT_URI = 
		Uri.parse("content://" + PROVIDER_NAME + "/queue");
	
	/**
	 * New episodes URI
	 */
	public static final Uri NEW_EPISODES_CONTENT_URI =
		Uri.parse("content://" + PROVIDER_NAME + "/new");
	
	private static final String PROVIDER_TYPE =
		"vnd.leifandersen.provider.shows ";

	private static final String TAG = "ShowsProvider";

	// For the shows table
	/**
	 * The Row ID
	 */
	public static final String _ID = "_id";
	
	/**
	 * The show's or episode's title
	 */
	public static final String TITLE = "title";
	
	/**
	 * The show's or episode's author.
	 */
	public static final String AUTHOR = "author";
	
	/**
	 * The URI of the show's RSS Feed.
	 */
	public static final String FEED = "feed";
	
	/**
	 * The location of the show's or episode's image on the filesystem.
	 */
	public static final String IMAGE = "image";

	/**
	 * The episode description.
	 */
	public static final String DESCRIPTION = "description";
	
	/**
	 * The frequency the show should be updated.
	 */
	public static final String UPDATE_FREQUENCY = "update_frequency";
	
	/**
	 * The amount of episodes to keep.
	 */
	public static final String EPISODES_TO_KEEP = "episodes_to_keep";
	
	/**
	 * How long an episode stays on the device.
	 */
	public static final String EPISODE_EXPIRATION_TIME = "episode_expiration_time";
	
	/**
	 * The last time the show was updated.	
	 */
	public static final String PREVIOUS_UPDATE_TIME = "previous_update_time";
	
	// For the episodes tables
	/**
	 * The location for the actual media of the show
	 */
	public static final String MEDIA = "media";

	/**
	 * The date the show was released
	 */
	public static final String DATE = "date";
	
	/**
	 * Whether the episode has been played or not.
	 */
	public static final String PLAYED = "played";
	
	/**
	 * The length of the episode.
	 */
	public static final String LENGTH = "length";
	
	/**
	 * The last position the user was listening at.
	 */
	public static final String POSITION = "position";
	
	// For the queue
	/**
	 * Show the episode is from
	 */
	public static final String SHOW_TITLE = "show_title";

	
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "Shows";
	private static final String SUBSCRIPTIONS_TABLE_NAME = "subscriptions";
	private static final String QUEUE_TABLE_NAME = "queue";
	private static final String NEW_EPISODES_TABLE_NAME = "newepisodes";
	private static final String SUBSCRIPTIONS_TABLE_CREATE = 
		"CREATE TABLE " + SUBSCRIPTIONS_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ FEED + " TEXT,"
		+ DESCRIPTION + " TEXT,"
		+ IMAGE + " TEXT," 
		+ UPDATE_FREQUENCY + " INTEGER," 
		+ EPISODES_TO_KEEP + " INTEGER,"
		+ EPISODE_EXPIRATION_TIME + " INTEGER," 
		+ PREVIOUS_UPDATE_TIME + " INTEGER" + ");";
	private static final String QUEUE_TABLE_CREATE =
		"CREATE TABLE " + QUEUE_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ SHOW_TITLE + " TEXT,"
		+ IMAGE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ PLAYED + " BOOLEAN" + ");";
	private static final String NEW_EPISODES_TABLE_CREATE = 
		"CREATE TABLE " + NEW_EPISODES_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ SHOW_TITLE + " TEXT,"
		+ IMAGE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ LENGTH + " INTEGER,"
		+ POSITION + " INTEGER,"
		+ PLAYED + " BOOLEAN" + ");";
	
	private static final String createTableString(final String tableName) {
		return 	"CREATE TABLE IF NOT EXISTS " + tableName + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ PLAYED + " BOOLEAN" + ");";
	}
	
	private static final String SHOW = "show";
	private static final String EPISODE = "episode";
	private static final String SPECIAL_EPISODE = "specialepisode";
	private static final String EMPTY_DATE = "";
	
	private static final int SUBSCRIPTIONS = 1;
	private static final int SUBSCRIPTION_ID = 2;<commit_msg>Fixed the database creation.<commit_after>package net.leifandersen.mobile.android.netcatch.providers;

import java.util.List;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;

/**
 * Manages the content provider for all show data.
 * 
 * @author <NAME>
 *
 */
public class ShowsProvider extends ContentProvider {

	/**
	 * The provider name for shows subscriptions and episodes.
	 */
	public static final String PROVIDER_NAME = 
		"net.leifandersen.provider.Shows";

	/**
	 * The Subscriptions URI.
	 */
	public static final Uri SUBSCRIPCTIONS_CONTENT_URI = 
		Uri.parse("content://" + PROVIDER_NAME + "/subscriptions");

	/**
	 * The queue URI
	 */
	public static final Uri QUEUE_CONTENT_URI = 
		Uri.parse("content://" + PROVIDER_NAME + "/queue");
	
	/**
	 * New episodes URI
	 */
	public static final Uri NEW_EPISODES_CONTENT_URI =
		Uri.parse("content://" + PROVIDER_NAME + "/new");
	
	private static final String PROVIDER_TYPE =
		"vnd.leifandersen.provider.shows ";

	private static final String TAG = "ShowsProvider";

	// For the shows table
	/**
	 * The Row ID
	 */
	public static final String _ID = "_id";
	
	/**
	 * The show's or episode's title
	 */
	public static final String TITLE = "title";
	
	/**
	 * The show's or episode's author.
	 */
	public static final String AUTHOR = "author";
	
	/**
	 * The URI of the show's RSS Feed.
	 */
	public static final String FEED = "feed";
	
	/**
	 * The location of the show's or episode's image on the filesystem.
	 */
	public static final String IMAGE = "image";

	/**
	 * The episode description.
	 */
	public static final String DESCRIPTION = "description";
	
	/**
	 * The frequency the show should be updated.
	 */
	public static final String UPDATE_FREQUENCY = "update_frequency";
	
	/**
	 * The amount of episodes to keep.
	 */
	public static final String EPISODES_TO_KEEP = "episodes_to_keep";
	
	/**
	 * How long an episode stays on the device.
	 */
	public static final String EPISODE_EXPIRATION_TIME = "episode_expiration_time";
	
	/**
	 * The last time the show was updated.	
	 */
	public static final String PREVIOUS_UPDATE_TIME = "previous_update_time";
	
	// For the episodes tables
	/**
	 * The location for the actual media of the show
	 */
	public static final String MEDIA = "media";

	/**
	 * The date the show was released
	 */
	public static final String DATE = "date";
	
	/**
	 * Whether the episode has been played or not.
	 */
	public static final String PLAYED = "played";
	
	/**
	 * The length of the episode.
	 */
	public static final String LENGTH = "length";
	
	/**
	 * The last position the user was listening at.
	 */
	public static final String POSITION = "position";
	
	// For the queue
	/**
	 * Show the episode is from
	 */
	public static final String SHOW_TITLE = "show_title";

	
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "Shows";
	private static final String SUBSCRIPTIONS_TABLE_NAME = "subscriptions";
	private static final String QUEUE_TABLE_NAME = "queue";
	private static final String NEW_EPISODES_TABLE_NAME = "newepisodes";
	private static final String SUBSCRIPTIONS_TABLE_CREATE = 
		"CREATE TABLE " + SUBSCRIPTIONS_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ FEED + " TEXT,"
		+ DESCRIPTION + " TEXT,"
		+ IMAGE + " TEXT," 
		+ UPDATE_FREQUENCY + " INTEGER," 
		+ EPISODES_TO_KEEP + " INTEGER,"
		+ EPISODE_EXPIRATION_TIME + " INTEGER," 
		+ PREVIOUS_UPDATE_TIME + " INTEGER" + ");";
	private static final String QUEUE_TABLE_CREATE =
		"CREATE TABLE " + QUEUE_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ SHOW_TITLE + " TEXT,"
		+ IMAGE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ PLAYED + " BOOLEAN" + ");";
	private static final String NEW_EPISODES_TABLE_CREATE = 
		"CREATE TABLE " + NEW_EPISODES_TABLE_NAME + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ SHOW_TITLE + " TEXT,"
		+ IMAGE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ PLAYED + " BOOLEAN" + ");";
	
	private static final String createTableString(final String tableName) {
		return 	"CREATE TABLE IF NOT EXISTS " + tableName + " ("
		+ _ID + " INTEGER PRIMARY KEY,"
		+ TITLE + " TEXT,"
		+ AUTHOR + " TEXT,"
		+ DESCRIPTION + " TEXT," 
		+ MEDIA + " TEXT, "
		+ DATE + " TEXT, "
		+ LENGTH + " INTEGER,"
		+ POSITION + " INTEGER,"
		+ PLAYED + " BOOLEAN" + ");";
	}
	
	private static final String SHOW = "show";
	private static final String EPISODE = "episode";
	private static final String SPECIAL_EPISODE = "specialepisode";
	private static final String EMPTY_DATE = "";
	
	private static final int SUBSCRIPTIONS = 1;
	private static final int SUBSCRIPTION_ID = 2;
{'fraction_non_alphanumeric': 0.1181430601610611, 'fraction_numerical': 0.0005684509711037423, 'mean_word_length': 3.4596535699197295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563443', 'n_tokens_mistral': 3756, 'n_tokens_neox': 3262, 'n_words': 1004}