Skip to content

Commit

Permalink
Añadir retrocompatibilidad con sistema antiguo de almacenamiento de RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
juanro49 committed Jan 22, 2020
1 parent 2185677 commit 379fda8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/src/main/java/org/juanro/feedtv/BBDD/FeedDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public void crearTabla(String tabla)
public void eliminarTabla(String tabla)
{
getWritableDatabase().execSQL("DROP TABLE IF EXISTS " + tabla);
getWritableDatabase().execSQL("DROP TABLE IF EXISTS " + tabla + "_");
}

/**
Expand All @@ -157,7 +158,11 @@ public void eliminarTabla(String tabla)
*/
public void setTabla(String tabla)
{
nombreTabla = tabla;
Cursor c;
c = getReadableDatabase().rawQuery("select name from sqlite_master where type = 'table' and name in('" + tabla + "', '" + tabla + "_')", null);
c.moveToFirst();
nombreTabla = c.getString(0);
c.close();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/juanro/feedtv/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void run()
encontrado = true;
viewModel.setUrl(url);

FeedDatabase.getInstance(MainActivity.this).setTabla(fuente + "_");
FeedDatabase.getInstance(MainActivity.this).setTabla(fuente);

// Obtener Feed
viewModel.fetchFeed(getApplicationContext());
Expand Down Expand Up @@ -168,7 +168,7 @@ public void onClick(DialogInterface dialog, int id)

// Eliminar fuente de la base de datos y de la lista
fuente.eliminarEntradas(elemento);
FeedDatabase.getInstance(MainActivity.this).eliminarTabla(elemento + "_");
FeedDatabase.getInstance(MainActivity.this).eliminarTabla(elemento);
adapter.remove(elemento);
fuente.close();

Expand Down

0 comments on commit 379fda8

Please sign in to comment.