优化一下删除功能,根据角色删除全部数据
package com.example.helloworld;import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import com.example.helloworld.database.UserDbHelper;
public class CreateData extends AppCompatActivity implements View.OnClickListener {
private Button del;
private UserDbHelper mHelper;
private RadioGroup role;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_data);
role = findViewById(R.id.role);
del = findViewById(R.id.del);
del.setOnClickListener(this);
}
@Override
protected void onStart(){
super.onStart();
mHelper = UserDbHelper.getInstance(this);
mHelper.openReadLink();
mHelper.openWriteLink();
}
@Override
protected void onStop(){
super.onStop();
mHelper.closeLink();
}
@Override
public void onClick(View v) {
if(v.getId()==R.id.del){
mHelper.deleteAll(role.toString());
}
}
} 标签:应用,安卓,del,void,mHelper,Override,import,android,日记 From: https://www.cnblogs.com/dddjm/p/18030911