Merge pull request #2311 from dklimkin/PodDBAdapter

Reducing lock contention on PodDbAdapter.
This commit is contained in:
Martin Fietz 2017-04-23 14:42:18 +02:00 committed by GitHub
commit e76e78cb56
1 changed files with 112 additions and 80 deletions

View File

@ -15,9 +15,12 @@ import android.text.TextUtils;
import android.util.Log;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.event.ProgressEvent;
@ -40,7 +43,7 @@ import de.greenrobot.event.EventBus;
* Implements methods for accessing the database
*/
public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
private static final String DATABASE_NAME = "Antennapod.db";
@ -219,7 +222,7 @@ public class PodDBAdapter {
public static final String CREATE_TABLE_FAVORITES = "CREATE TABLE "
+ TABLE_NAME_FAVORITES + "(" + KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_FEEDITEM + " INTEGER," + KEY_FEED + " INTEGER)";
/**
* Select all columns from the feed-table
*/
@ -252,7 +255,7 @@ public class PodDBAdapter {
TABLE_NAME_FEEDS + "." + KEY_INCLUDE_FILTER,
TABLE_NAME_FEEDS + "." + KEY_EXCLUDE_FILTER
};
/**
* Select all columns from the feeditems-table except description and
* content-encoded.
@ -303,59 +306,87 @@ public class PodDBAdapter {
private static final String[] SEL_FI_EXTRA = {KEY_ID, KEY_DESCRIPTION,
KEY_CONTENT_ENCODED, KEY_FEED};
private static SQLiteDatabase db;
private static Context context;
private static PodDBHelper dbHelper;
private static volatile SQLiteDatabase db;
private static Lock dbLock = new ReentrantLock();
private static AtomicInteger counter = new AtomicInteger(0);
public static void init(Context context) {
PodDBAdapter.context = context.getApplicationContext();
}
public static synchronized PodDBAdapter getInstance() {
if(dbHelper == null) {
dbHelper = new PodDBHelper(PodDBAdapter.context, DATABASE_NAME, null);
}
private static class PodDBHelperholder {
public static final PodDBHelper dbHelper = new PodDBHelper(PodDBAdapter.context, DATABASE_NAME, null);
}
public static PodDBAdapter getInstance() {
dbHelper = PodDBHelperholder.dbHelper;
return new PodDBAdapter();
}
private PodDBAdapter() {}
private PodDBAdapter() {
}
public synchronized PodDBAdapter open() {
public PodDBAdapter open() {
int adapters = counter.incrementAndGet();
Log.v(TAG, "Opening DB #" + adapters);
if (db == null || !db.isOpen() || db.isReadOnly()) {
if ((db == null) || (!db.isOpen()) || (db.isReadOnly())) {
try {
db = dbHelper.getWritableDatabase();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
db.enableWriteAheadLogging();
dbLock.lock();
if ((db == null) || (!db.isOpen()) || (db.isReadOnly())) {
db = openDb();
}
} catch (SQLException ex) {
Log.e(TAG, Log.getStackTraceString(ex));
db = dbHelper.getReadableDatabase();
} finally {
dbLock.unlock();
}
}
return this;
}
public synchronized void close() {
private SQLiteDatabase openDb() {
SQLiteDatabase newDb = null;
try {
newDb = dbHelper.getWritableDatabase();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
newDb.enableWriteAheadLogging();
}
} catch (SQLException ex) {
Log.e(TAG, Log.getStackTraceString(ex));
newDb = dbHelper.getReadableDatabase();
}
return newDb;
}
public void close() {
int adapters = counter.decrementAndGet();
Log.v(TAG, "Closing DB #" + adapters);
if(adapters == 0) {
if (adapters == 0) {
Log.v(TAG, "Closing DB, really");
db.close();
try {
dbLock.lock();
db.close();
db = null;
} finally {
dbLock.unlock();
}
}
}
public static boolean deleteDatabase() {
PodDBAdapter adapter = getInstance();
adapter.open();
for (String tableName : ALL_TABLES) {
db.delete(tableName, "1", null);
try {
for (String tableName : ALL_TABLES) {
db.delete(tableName, "1", null);
}
return true;
} finally {
adapter.close();
}
adapter.close();
return true;
}
/**
@ -390,8 +421,8 @@ public class PodDBAdapter {
values.put(KEY_FLATTR_STATUS, feed.getFlattrStatus().toLong());
values.put(KEY_IS_PAGED, feed.isPaged());
values.put(KEY_NEXT_PAGE_LINK, feed.getNextPageLink());
if(feed.getItemFilter() != null && feed.getItemFilter().getValues().length > 0) {
values.put(KEY_HIDE, TextUtils.join( ",", feed.getItemFilter().getValues()));
if (feed.getItemFilter() != null && feed.getItemFilter().getValues().length > 0) {
values.put(KEY_HIDE, TextUtils.join(",", feed.getItemFilter().getValues()));
} else {
values.put(KEY_HIDE, "");
}
@ -415,7 +446,7 @@ public class PodDBAdapter {
ContentValues values = new ContentValues();
values.put(KEY_AUTO_DOWNLOAD, prefs.getAutoDownload());
values.put(KEY_KEEP_UPDATED, prefs.getKeepUpdated());
values.put(KEY_AUTO_DELETE_ACTION,prefs.getAutoDeleteAction().ordinal());
values.put(KEY_AUTO_DELETE_ACTION, prefs.getAutoDeleteAction().ordinal());
values.put(KEY_USERNAME, prefs.getUsername());
values.put(KEY_PASSWORD, prefs.getPassword());
values.put(KEY_INCLUDE_FILTER, prefs.getFilter().getIncludeFilter());
@ -424,10 +455,11 @@ public class PodDBAdapter {
}
public void setFeedItemFilter(long feedId, Set<String> filterValues) {
Log.d(TAG, "setFeedItemFilter() called with: " + "feedId = [" + feedId + "], " +
"filterValues = [" + TextUtils.join(",", filterValues) + "]");
String valuesList = TextUtils.join(",", filterValues);
Log.d(TAG, String.format(
"setFeedItemFilter() called with: feedId = [%d], filterValues = [%s]", feedId, valuesList));
ContentValues values = new ContentValues();
values.put(KEY_HIDE, TextUtils.join(",", filterValues));
values.put(KEY_HIDE, valuesList);
db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(feedId)});
}
@ -458,7 +490,7 @@ public class PodDBAdapter {
image.setId(db.insert(TABLE_NAME_FEED_IMAGES, null, values));
} else {
db.update(TABLE_NAME_FEED_IMAGES, values, KEY_ID + "=?",
new String[]{String.valueOf(image.getId())});
new String[]{String.valueOf(image.getId())});
}
final FeedComponent owner = image.getOwner();
@ -746,9 +778,9 @@ public class PodDBAdapter {
setFeed(item.getFeed());
}
values.put(KEY_FEED, item.getFeed().getId());
if(item.isNew()) {
if (item.isNew()) {
values.put(KEY_READ, FeedItem.NEW);
} else if(item.isPlayed()) {
} else if (item.isPlayed()) {
values.put(KEY_READ, FeedItem.PLAYED);
} else {
values.put(KEY_READ, FeedItem.UNPLAYED);
@ -808,7 +840,8 @@ public class PodDBAdapter {
/**
* Sets the 'read' attribute of the item.
* @param read must be one of FeedItem.PLAYED, FeedItem.NEW, FeedItem.UNPLAYED
*
* @param read must be one of FeedItem.PLAYED, FeedItem.NEW, FeedItem.UNPLAYED
* @param itemIds items to change the value of
*/
public void setFeedItemRead(int read, long... itemIds) {
@ -851,8 +884,8 @@ public class PodDBAdapter {
public void setFeedLastUpdateFailed(long feedId, boolean failed) {
final String sql = "UPDATE " + TABLE_NAME_FEEDS
+ " SET " + KEY_LAST_UPDATE_FAILED+ "=" + (failed ? "1" : "0")
+ " WHERE " + KEY_ID + "="+ feedId;
+ " SET " + KEY_LAST_UPDATE_FAILED + "=" + (failed ? "1" : "0")
+ " WHERE " + KEY_ID + "=" + feedId;
db.execSQL(sql);
}
@ -892,7 +925,7 @@ public class PodDBAdapter {
public void setFeedsItemsAutoDownload(Feed feed, boolean autoDownload) {
final String sql = "UPDATE " + TABLE_NAME_FEED_ITEMS
+ " SET " + KEY_AUTO_DOWNLOAD + "="+ (autoDownload ? "1" : "0")
+ " SET " + KEY_AUTO_DOWNLOAD + "=" + (autoDownload ? "1" : "0")
+ " WHERE " + KEY_FEED + "=" + feed.getId();
db.execSQL(sql);
}
@ -994,8 +1027,8 @@ public class PodDBAdapter {
public void removeFeedMedia(FeedMedia media) {
// delete download log entries for feed media
db.delete(TABLE_NAME_DOWNLOAD_LOG, KEY_FEEDFILE + "=? AND " + KEY_FEEDFILETYPE +"=?",
new String[] { String.valueOf(media.getId()), String.valueOf(FeedMedia.FEEDFILETYPE_FEEDMEDIA) });
db.delete(TABLE_NAME_DOWNLOAD_LOG, KEY_FEEDFILE + "=? AND " + KEY_FEEDFILETYPE + "=?",
new String[]{String.valueOf(media.getId()), String.valueOf(FeedMedia.FEEDFILETYPE_FEEDMEDIA)});
db.delete(TABLE_NAME_FEED_MEDIA, KEY_ID + "=?",
new String[]{String.valueOf(media.getId())});
@ -1048,10 +1081,10 @@ public class PodDBAdapter {
}
// delete download log entries for feed
db.delete(TABLE_NAME_DOWNLOAD_LOG, KEY_FEEDFILE + "=? AND " + KEY_FEEDFILETYPE + "=?",
new String[]{String.valueOf(feed.getId()), String.valueOf(Feed.FEEDFILETYPE_FEED)});
new String[]{String.valueOf(feed.getId()), String.valueOf(Feed.FEEDFILETYPE_FEED)});
db.delete(TABLE_NAME_FEEDS, KEY_ID + "=?",
new String[]{String.valueOf(feed.getId())});
new String[]{String.valueOf(feed.getId())});
db.setTransactionSuccessful();
} catch (SQLException e) {
Log.e(TAG, Log.getStackTraceString(e));
@ -1190,12 +1223,12 @@ public class PodDBAdapter {
* cursor uses the FEEDITEM_SEL_FI_SMALL selection.
*/
public final Cursor getQueueCursor() {
Object[] args = new String[] {
Object[] args = new String[]{
SEL_FI_SMALL_STR,
TABLE_NAME_FEED_ITEMS, TABLE_NAME_QUEUE,
TABLE_NAME_FEED_ITEMS + "." + KEY_ID,
TABLE_NAME_QUEUE + "." + KEY_FEEDITEM,
TABLE_NAME_QUEUE + "." + KEY_ID };
TABLE_NAME_QUEUE + "." + KEY_ID};
String query = String.format("SELECT %s FROM %s INNER JOIN %s ON %s=%s ORDER BY %s", args);
return db.rawQuery(query, null);
}
@ -1206,12 +1239,12 @@ public class PodDBAdapter {
public final Cursor getFavoritesCursor() {
Object[] args = new String[] {
Object[] args = new String[]{
SEL_FI_SMALL_STR,
TABLE_NAME_FEED_ITEMS, TABLE_NAME_FAVORITES,
TABLE_NAME_FEED_ITEMS + "." + KEY_ID,
TABLE_NAME_FAVORITES + "." + KEY_FEEDITEM,
TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE };
TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE};
String query = String.format("SELECT %s FROM %s INNER JOIN %s ON %s=%s ORDER BY %s DESC", args);
return db.rawQuery(query, null);
}
@ -1239,10 +1272,10 @@ public class PodDBAdapter {
public void setFeedItems(int oldState, int newState, long feedId) {
String sql = "UPDATE " + TABLE_NAME_FEED_ITEMS + " SET " + KEY_READ + "=" + newState;
if(feedId > 0) {
if (feedId > 0) {
sql += " WHERE " + KEY_FEED + "=" + feedId;
}
if(FeedItem.NEW <= oldState && oldState <= FeedItem.PLAYED) {
if (FeedItem.NEW <= oldState && oldState <= FeedItem.PLAYED) {
sql += feedId > 0 ? " AND " : " WHERE ";
sql += KEY_READ + "=" + oldState;
}
@ -1268,7 +1301,7 @@ public class PodDBAdapter {
* The returned cursor uses the FEEDITEM_SEL_FI_SMALL selection.
*/
public final Cursor getNewItemsCursor() {
Object[] args = new String[] {
Object[] args = new String[]{
SEL_FI_SMALL_STR,
TABLE_NAME_FEED_ITEMS,
TABLE_NAME_FEEDS,
@ -1302,7 +1335,7 @@ public class PodDBAdapter {
* @throws IllegalArgumentException if limit < 0
*/
public final Cursor getCompletedMediaCursor(int limit) {
if(limit < 0) {
if (limit < 0) {
throw new IllegalArgumentException("Limit must be >= 0");
}
@ -1359,11 +1392,10 @@ public class PodDBAdapter {
if (size == 1) {
return "(?)";
}
StringBuilder builder = new StringBuilder("(");
for (int i = 0; i < size - 1; i++) {
builder.append("?,");
}
builder.append("?)");
StringBuilder builder =
new StringBuilder("(")
.append(TextUtils.join(",", Collections.nCopies(size, "?")))
.append(")");
return builder.toString();
}
@ -1397,7 +1429,7 @@ public class PodDBAdapter {
+ " INNER JOIN " + TABLE_NAME_FEEDS
+ " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " INNER JOIN " + TABLE_NAME_FEED_MEDIA
+ " ON " + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM + "=" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID
+ " ON " + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM + "=" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID
+ " WHERE " + TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOAD_URL + "=" + escapedEpisodeUrl
+ " AND " + TABLE_NAME_FEEDS + "." + KEY_DOWNLOAD_URL + "=" + escapedPodcastUrl;
Log.d(TAG, "SQL: " + query);
@ -1448,10 +1480,10 @@ public class PodDBAdapter {
public final LongIntMap getFeedCounters(long... feedIds) {
int setting = UserPreferences.getFeedCounterSetting();
String whereRead;
switch(setting) {
switch (setting) {
case UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM:
whereRead = "(" + KEY_READ + "=" + FeedItem.NEW +
" OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
" OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
break;
case UserPreferences.FEED_COUNTER_SHOW_NEW:
whereRead = KEY_READ + "=" + FeedItem.NEW;
@ -1497,7 +1529,7 @@ public class PodDBAdapter {
long feedId = c.getLong(0);
int count = c.getInt(1);
result.put(feedId, count);
} while(c.moveToNext());
} while (c.moveToNext());
}
c.close();
return result;
@ -1605,8 +1637,8 @@ public class PodDBAdapter {
if (feedID != 0) {
// search items in specific feed
return db.rawQuery("SELECT " + TextUtils.join(", ", FEEDITEM_SEL_FI_SMALL) + " FROM " + TABLE_NAME_FEED_ITEMS
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS+"."+KEY_FEED+"="+TABLE_NAME_FEEDS+"."+KEY_ID
+ " WHERE " + KEY_FEED
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " WHERE " + KEY_FEED
+ "=? AND " + KEY_AUTHOR + " LIKE '%"
+ prepareSearchQuery(query) + "%' ORDER BY "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE + " DESC",
@ -1615,7 +1647,7 @@ public class PodDBAdapter {
} else {
// search through all items
return db.rawQuery("SELECT " + TextUtils.join(", ", FEEDITEM_SEL_FI_SMALL) + " FROM " + TABLE_NAME_FEED_ITEMS
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS+"."+KEY_FEED+"="+TABLE_NAME_FEEDS+"."+KEY_ID
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " WHERE " + KEY_AUTHOR + " LIKE '%"
+ prepareSearchQuery(query) + "%' ORDER BY "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE + " DESC",
@ -1628,7 +1660,7 @@ public class PodDBAdapter {
if (feedID != 0) {
// search items in specific feed
return db.rawQuery("SELECT " + TextUtils.join(", ", FEEDITEM_SEL_FI_SMALL) + " FROM " + TABLE_NAME_FEED_ITEMS
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS+"."+KEY_FEED+"="+TABLE_NAME_FEEDS+"."+KEY_ID
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " WHERE " + KEY_FEED
+ "=? AND " + KEY_FEED_IDENTIFIER + " LIKE '%"
+ prepareSearchQuery(query) + "%' ORDER BY "
@ -1638,7 +1670,7 @@ public class PodDBAdapter {
} else {
// search through all items
return db.rawQuery("SELECT " + TextUtils.join(", ", FEEDITEM_SEL_FI_SMALL) + " FROM " + TABLE_NAME_FEED_ITEMS
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS+"."+KEY_FEED+"="+TABLE_NAME_FEEDS+"."+KEY_ID
+ " JOIN " + TABLE_NAME_FEEDS + " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " WHERE " + KEY_FEED_IDENTIFIER + " LIKE '%"
+ prepareSearchQuery(query) + "%' ORDER BY "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE + " DESC",
@ -1842,7 +1874,7 @@ public class PodDBAdapter {
KEY_LINK,
KEY_CHAPTER_TYPE));
}
if(oldVersion <= 14) {
if (oldVersion <= 14) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " ADD COLUMN " + KEY_AUTO_DOWNLOAD + " INTEGER");
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
@ -1865,7 +1897,7 @@ public class PodDBAdapter {
db.execSQL(PodDBAdapter.CREATE_INDEX_QUEUE_FEEDITEM);
db.execSQL(PodDBAdapter.CREATE_INDEX_SIMPLECHAPTERS_FEEDITEM);
}
if(oldVersion <= 15) {
if (oldVersion <= 15) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + KEY_HAS_EMBEDDED_PICTURE + " INTEGER DEFAULT -1");
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
@ -1875,7 +1907,7 @@ public class PodDBAdapter {
+ " FROM " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " WHERE " + KEY_DOWNLOADED + "=1 "
+ " AND " + KEY_HAS_EMBEDDED_PICTURE + "=-1", null);
if(c.moveToFirst()) {
if (c.moveToFirst()) {
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
do {
String fileUrl = c.getString(0);
@ -1885,20 +1917,20 @@ public class PodDBAdapter {
if (image != null) {
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " SET " + KEY_HAS_EMBEDDED_PICTURE + "=1"
+ " WHERE " + KEY_FILE_URL + "='"+ fileUrl + "'");
+ " WHERE " + KEY_FILE_URL + "='" + fileUrl + "'");
} else {
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " SET " + KEY_HAS_EMBEDDED_PICTURE + "=0"
+ " WHERE " + KEY_FILE_URL + "='"+ fileUrl + "'");
+ " WHERE " + KEY_FILE_URL + "='" + fileUrl + "'");
}
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
} while(c.moveToNext());
} while (c.moveToNext());
}
c.close();
}
if(oldVersion <= 16) {
if (oldVersion <= 16) {
String selectNew = "SELECT " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + KEY_ID
+ " FROM " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " INNER JOIN " + PodDBAdapter.TABLE_NAME_FEED_MEDIA + " ON "
@ -1912,29 +1944,29 @@ public class PodDBAdapter {
+ PodDBAdapter.TABLE_NAME_FEED_MEDIA + "." + KEY_DOWNLOADED + " = 0 AND " // undownloaded
+ PodDBAdapter.TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " = 0 AND " // not partially played
+ PodDBAdapter.TABLE_NAME_QUEUE + "." + KEY_ID + " IS NULL"; // not in queue
String sql = "UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
String sql = "UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " SET " + KEY_READ + "=" + FeedItem.NEW
+ " WHERE " + KEY_ID + " IN (" + selectNew + ")";
Log.d("Migration", "SQL: " + sql);
db.execSQL(sql);
}
if(oldVersion <= 17) {
if (oldVersion <= 17) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DELETE_ACTION + " INTEGER DEFAULT 0");
}
if(oldVersion < 1030005) {
if (oldVersion < 1030005) {
db.execSQL("UPDATE FeedItems SET auto_download=0 WHERE " +
"(read=1 OR id IN (SELECT feeditem FROM FeedMedia WHERE position>0 OR downloaded=1)) " +
"AND id NOT IN (SELECT feeditem FROM Queue)");
}
if(oldVersion < 1040001) {
if (oldVersion < 1040001) {
db.execSQL(CREATE_TABLE_FAVORITES);
}
if (oldVersion < 1040002) {
if (oldVersion < 1040002) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
+ " ADD COLUMN " + PodDBAdapter.KEY_LAST_PLAYED_TIME + " INTEGER DEFAULT 0");
}
if(oldVersion < 1040013) {
if (oldVersion < 1040013) {
db.execSQL(PodDBAdapter.CREATE_INDEX_FEEDITEMS_PUBDATE);
db.execSQL(PodDBAdapter.CREATE_INDEX_FEEDITEMS_READ);
}
@ -1988,9 +2020,9 @@ public class PodDBAdapter {
if (oldVersion < 1050004) {
// prevent old timestamps to be misinterpreted as ETags
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEEDS
+" SET " + PodDBAdapter.KEY_LASTUPDATE + "=NULL");
+ " SET " + PodDBAdapter.KEY_LASTUPDATE + "=NULL");
}
if(oldVersion < 1060200) {
if (oldVersion < 1060200) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_CUSTOM_TITLE + " TEXT");
}