How to delete MySQL database news?

1

In this link teaches you to list comments (in my case news) using external database (project download).

How can I delete a news item when selecting, and still have a Dialog appear asking if I want to delete the news from the external database?

This is the code for INSERT :

public void chamaCadastrarNoticia(){
    setContentView(R.layout.cadastrar_noticia);

    editTituloNoticia=(EditText) findViewById(R.id.editTituloNoticia);
    editNoticia=(EditText) findViewById(R.id.editNoticia);
    btCadastrarNoticia=(Button) findViewById(R.id.btCadastrarNoticia);

    btCadastrarNoticia.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {                
            String vazios = "";
            if (editTituloNoticia.getText().toString().equals("")) 
                vazios="Campo Titulo não pode estar vazio\n\n"; 

            if (editNoticia.getText().toString().equals("")) 
                vazios="Campo Noticia não pode estar vazio\n\n";            

            if  (editTituloNoticia.getText().toString().equals("") || editNoticia.getText().toString().equals("")) 
                mensagemExibir("Erro:", ""+vazios);
            else {                
                String urlPost="#url"; // URL
                String urlGet="#url   ?titulo="+editTituloNoticia.getText().toString()+"noticia="+editNoticia.getText().toString(); // URL
                ArrayList<NameValuePair> iparametrosPost = new ArrayList<NameValuePair>();
                iparametrosPost.add(new BasicNameValuePair("titulo",editTituloNoticia.getText().toString()));   
                iparametrosPost.add(new BasicNameValuePair("noticia",editNoticia.getText().toString()));            
                String respostaRetornada = null;

                try {
                    respostaRetornada = ConexaoHttpClient.executaHttpPost(urlPost, iparametrosPost);
                    String resposta = respostaRetornada.toString();
                    resposta = resposta.replaceAll("\s+", "");

                    if (resposta.equals("1")) {
                        mensagemExibir("Cadastrado:", "Acesse Listar Noticias para ver a noticia cadastrada");
                    }

                    chamaIndexAdmin();
                }
                catch(Exception erro){
                    Log.i("erro", "erro = "+erro);
                    mensagemExibir("Erro", "Erro ao gravar: "+erro);
                }
            }
        }
    });     
}
    
asked by anonymous 11.03.2014 / 19:40

1 answer

2

To make a user confirm you can use Dialog by placing a requisition to the server on the positive button.

To delete a comment (news, in your case), I believe the best option is to create a new service (removeComment.php, for example) that will be called and pass as a parameter some news identifier (I recommend being the identifier itself of the database table)

Then just update the list on the device

    
12.03.2014 / 04:36