Exemplo n.º 1
0
  public void update(View view) {

    SQLiteDatabase database = dbHelper.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put("price", 9.9);
    database.update(
        MyDatabaseHelper.TABLE_BOOK, values, "name = ?", new String[] {"Learn Android From 0"});
    database.close();
  }
Exemplo n.º 2
0
  public void add(View view) {
    SQLiteDatabase database = dbHelper.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("author", "lovexiaov");
    values.put("price", 99.0);
    values.put("page", 399);
    values.put("name", "Learn Android From 0");
    database.insert(MyDatabaseHelper.TABLE_BOOK, null, values);
    Toast.makeText(AtyUseDatabase.this, "add data", Toast.LENGTH_SHORT).show();
    database.close();
  }
Exemplo n.º 3
0
 public void delete(View view) {
   SQLiteDatabase database = dbHelper.getWritableDatabase();
   database.delete(MyDatabaseHelper.TABLE_BOOK, "name = ?", new String[] {"Learn Android From 0"});
   database.close();
 }