Android adds pictures and alarm clocks to the database and displays them with listview 2

Keywords: Database Android SQL

Android adds pictures and alarm clocks to the database and displays them with listview 2

Novice on the road, please give me more advice

Continue last time, the teacher proposed to add two more alarm clocks. Although it was not satisfactory, it also made
Because it's not so hard for a novice to simplify his intelligence

The effect is still OK. I changed the image storage mode when I did this

    public byte[] img()//Picture turnbyte
    {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         Bitmap image = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();
         image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
         return baos.toByteArray();
   }
  public long insert(byte[] img) //Save the picture to byte database
      { 

          ContentValues values = new ContentValues();
          str2=spinner1.getSelectedItem().toString();
          values.put("image", img);
          values.put("name", editText2yl.getText().toString()+str2);
            values.put("word", editText1.getText().toString());
            values.put("oneclock",date);
            values.put("setclock", mCalendar.getTimeInMillis()+"");
//          values.put("twoclock",date2);
//          values.put("set2clock", ca.getTimeInMillis()+"");
//          values.put("threeclock",date3);
//          values.put("set3clock", c.getTimeInMillis()+"");
//          int count = db.update("user", values, "name=? and word=?", new String[]{"a","b"});
             _id = SQL.insert(db, "user", values);
//          db.insert("user", null, values);

//          Toast.makeText(MainActivity.this, "Modified successfully:" + count, Toast.LENGTH_SHORT).show();

            Cursor cursor=db.rawQuery("select * from user", null);

            Intent intent=getIntent();

            while(cursor.moveToNext()){

                if(cursor.getLong(4)>0)
                ObjectPool.mAlarmHelper.openAlarm(Integer.parseInt(cursor.getString(0)), 
                        intent.getStringExtra("title"),intent.getStringExtra("content")+"                                                I wish you a speedy recovery!(*^_^*)",
                        cursor.getLong(4));

                if(cursor.getLong(5)>0)
                ObjectPool.mAlarmHelper.openAlarm(Integer.parseInt(cursor.getString(0)), 
                        intent.getStringExtra("title"),intent.getStringExtra("content")+"                                                I wish you a speedy recovery!(*^_^*)", 
                        cursor.getLong(5));

            //                  
            }
          return _id;
      }

I'm stupid. That's all I can do

button1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub,

//              update2();


//              update3();

                insert(img());

                insert2(img());

                insert3(img());
            }
        });

In this way, three alarm prompts will be displayed after adding. I hope you like it. After all the requirements are completed, I will give you a complete code

Posted by BAM1979 on Tue, 31 Mar 2020 14:33:17 -0700