diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 232b563..32bd02b 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -16,6 +16,7 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index be0cc41..915410e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/app/src/main/java/com/kongzue/dbv3demo/MainActivity.java b/app/src/main/java/com/kongzue/dbv3demo/MainActivity.java index 58757f3..a21dd13 100644 --- a/app/src/main/java/com/kongzue/dbv3demo/MainActivity.java +++ b/app/src/main/java/com/kongzue/dbv3demo/MainActivity.java @@ -32,6 +32,7 @@ public class MainActivity extends AppCompatActivity { private Button btnAddDemoData; private Button btnAddJsonData; private Button btnAddMapData; + private Button btnAddOrUpdate; private EditText editName; private EditText editAge; private RadioGroup rgpGender; @@ -67,6 +68,7 @@ protected void onCreate(Bundle savedInstanceState) { btnAddDemoData = findViewById(R.id.btn_add_demo_data); btnAddJsonData = findViewById(R.id.btn_add_json_data); btnAddMapData = findViewById(R.id.btn_add_map_data); + btnAddOrUpdate = findViewById(R.id.btn_add_or_update); editName = findViewById(R.id.edit_name); editAge = findViewById(R.id.edit_age); rgpGender = findViewById(R.id.rgp_gender); @@ -319,6 +321,20 @@ public void onClick(View v) { logAllData(); } }); + + btnAddOrUpdate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Map map = new HashMap<>(); + map.put("username", "张三"); + map.put("age", 99); + map.put("gender", 1); + map.put("isVIP", false); + + DB.getTable("user").addOrUpdate("username",new DBData(map)); + logAllData(); + } + }); } private void addDemoData() { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e7a0dc1..bb4ecc8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -52,6 +52,12 @@ android:layout_height="wrap_content" android:text="通过Map添加数据" /> +