Guest User

Untitled

a guest
Dec 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. ALTER TABLE "poems_table" RENAME TO 'poems_table_TMP';
  2. CREATE TABLE
  3. "poems_table" ( "id" INTEGERL, "title" text, "poem" text,
  4. "subject" text, "years" text, "favorite" INTEGER, PRIMARY KEY ("id") );
  5.  
  6. INSERT INTO "poems_table" ("id", "title", "poem", "subject",
  7. "years", "favorite") SELECT "id", "title", "poem", "subject",
  8. "years", "favorite" FROM "poems_table_TMP";
  9. DROP TABLE
  10. "poems_table_TMP";
  11.  
  12. public class PoemsDbHelper extends SQLiteAssetHelper {
  13.  
  14. private static String DB_NAME = "info.db";
  15. private static final int DB_VERSION = 2;
  16.  
  17. public PoemsDbHelper(Context context) {
  18. super(context, DB_NAME, null, DB_VERSION);
  19. }
  20.  
  21.  
  22. public Cursor getPoems_table() {
  23. // SQLiteDatabase db = getWritableDatabase();
  24. // db.close();
  25.  
  26. SQLiteDatabase db = getReadableDatabase();
  27. SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  28.  
  29. String[] sqlSelect = {"id", "title", "poem", "subject", "years", "favorite"};
  30. String sqlTables = "poems_table";
  31.  
  32. qb.setTables(sqlTables);
  33. Cursor c = qb.query(db, sqlSelect, null, null,
  34. null, null, null);
  35.  
  36. c.moveToFirst();
  37. return c;
  38.  
  39. }
Add Comment
Please, Sign In to add comment