2012-02-03 80 views
0

我是android新手。我正在構建一個小應用程序來刪除數據。我想刪除單個數據,但它正在刪除整個數據。我的代碼:Android應用程序刪除數據

import android.app.Activity; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 

    public class DelbookActivity extends Activity { 

/** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    Button btndel=(Button)findViewById(R.id.btndel); 
    btndel.setOnClickListener(new View.OnClickListener() { 
    EditText value1 = (EditText)findViewById(R.id.txtISBN); 

     public void onClick(View view) { 
      final String PROVIDER_NAME="net.learn2develop.provider.Book"; 
      String val1=(value1.getText().toString());  
       getContentResolver().delete(Uri.parse("content://"+PROVIDER_NAME+"/books"),val1,null); 

     }    
    }); 
} 

}

任何幫助非常接受。提前致謝。

回答

2

顯然其刪除整個事情:

getContentResolver().delete(Uri.parse("content://"+PROVIDER_NAME+"/books"),val1,null); 

這是說刪除整個表命名的書籍。嘗試定位特定的URI。

相關問題