public synchronized void save(SQLiteDatabase database) {
   ContentValues values = Gen_getValues();
   values.remove(GEN_FIELD__ID);
   // Never save the SSH password and passphrase.
   values.put(GEN_FIELD_SSHPASSWORD, "");
   values.put(GEN_FIELD_SSHPASSPHRASE, "");
   if (!getKeepPassword()) {
     values.put(GEN_FIELD_PASSWORD, "");
   }
   if (isNew()) {
     set_Id(database.insert(GEN_TABLE_NAME, null, values));
   } else {
     database.update(
         GEN_TABLE_NAME, values, GEN_FIELD__ID + " = ?", new String[] {Long.toString(get_Id())});
   }
 }
示例#2
0
 @OnClick({R.id.add_data, R.id.query_data})
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.add_data:
       ContentValues values = new ContentValues();
       values.put("name", "GOT");
       values.put("pages", 566);
       database.insert("Book", null, values);
       break;
     case R.id.query_data:
       Cursor cursor = database.query("Book", null, null, null, null, null, null);
       if (cursor != null) {
         while (cursor.moveToNext()) {
           String name = cursor.getString(cursor.getColumnIndex("name"));
           int pages = cursor.getInt(cursor.getColumnIndex("pages"));
           Log.d("TAG", "book names is " + name);
           Log.d("TAG", "book pages is " + pages);
         }
       }
       cursor.close();
       break;
   }
 }
 public void add(TimelineEvent timelineEvent) {
   Log.e("Timeline", " Created " + timelineEvent.caseId() + "--" + timelineEvent.title());
   SQLiteDatabase database = masterRepository.getWritableDatabase();
   database.insert(TIMELINEEVENT_TABLE_NAME, null, createValuesFor(timelineEvent));
 }