Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is advised to use the contentResolver's delete method to be injection safe?

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);
like image 503
Pentium10 Avatar asked Feb 27 '10 07:02

Pentium10


People also ask

How do I use content resolver?

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 .

What is the purpose of content resolver in Android?

Stay organized with collections Save and categorize content based on your preferences. This class provides applications access to the content model.

What does ContentResolver query () return?

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.

What is ContentResolver in Kotlin?

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.


1 Answers

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 );
like image 102
Gavin Bong Avatar answered Oct 06 '22 00:10

Gavin Bong