You can delete with content resolver by URI or by passing some parameters to the where parameter.
How do you make the parameters to be SQL Injection Safe?
Is it possible to use Prepared Statements with ContentResolver?
act.getContentResolver().delete(myuriwithid,null,null);
act.getContentResolver().delete(mybaseuri," name = '"+this.name"'",null);
When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolver object communicates with the provider object, an instance of a class that implements ContentProvider .
Stay organized with collections Save and categorize content based on your preferences. This class provides applications access to the content model.
The ContentResolver. query() client method always returns a Cursor. This cursor contains the column specified by the query projection. The cursor object provides read access to rows and columns.
With the help of Content Provider, you can either use other application's data or you can share your application's data with other applications. We have a class called ContentResolver, which helps us to manage the requests of data.
Use positional parameters.
public final int delete (Uri url, String where, String[] selectionArgs)
e.g.
ContentResolver cr = ...;
String where = "nameid=?";
String[] args = new String[] { "george" };
cr.delete( Stuff.CONTENT_URI, where, args );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With