Exemplo n.º 1
0
 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
   // TODO Auto-generated method stub
   db.execSQL(NotesContract.Note.getSqlDeleteEntries());
   db.execSQL(NotesContract.Tag.getSqlDeleteEntries());
   onCreate(db);
 }
Exemplo n.º 2
0
  public ArrayList<Note> Get_Notes() {
    try {
      notes_list.clear();
      SQLiteDatabase db = this.getReadableDatabase();
      SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
      builder.setTables(NotesContract.Note.FTS_TABLE_NAME);

      String[] projection = NotesContract.Note.getNotesColumns();

      Cursor cur = builder.query(db, projection, null, null, null, null, null, null);

      if (cur != null) {
        cur.moveToFirst();
        do {
          Note note = new Note();
          note.setNoteId(Integer.valueOf(cur.getString(0)));
          note.setNoteTitle(cur.getString(1));
          note.setNoteText(cur.getString(2));
          // add to list now:
          notes_list.add(note);
        } while (cur.moveToNext());
      }
      cur.close();
      return notes_list;
    } catch (Exception e) {
      Log.e("SELECT All notes", " " + e);
    }
    return notes_list;
  }
Exemplo n.º 3
0
  // SELECT operations
  // single note (based on note ID; returns Note) - FTS
  Note Get_Note(int id) {
    SQLiteDatabase db = this.getReadableDatabase();
    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables(NotesContract.Note.FTS_TABLE_NAME);

    String[] projection = NotesContract.Note.getNotesColumns();
    String selection = " docid = ?";
    String[] noteId = new String[] {String.valueOf(id)};

    Cursor cur = builder.query(db, projection, selection, noteId, null, null, null, null);

    if (cur != null) {
      cur.moveToFirst();
    }

    // now create Note object:
    Note note = new Note(Integer.parseInt(cur.getString(0)), cur.getString(1), cur.getString(2));
    cur.close();
    return note;
  }
Exemplo n.º 4
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   // TODO Auto-generated method stub
   db.execSQL(NotesContract.Note.getSqlCreateEntries());
   db.execSQL(NotesContract.Tag.getSqlCreateEntries());
 }