Search code examples
androidjunitandroid-contentprovider

Insert value missing in mock content resolver


I created a concrete class extending the ProviderTestCase2, and I'm writing test methods to test content provider's implementation of insert, delete, query, update, getType.

I used getMockContentResolver and passed in some random value, like

ContentValues cv = new ContentValues();
cv.put("key1", "value1");
cv.put("key2", "value2");

Uri uri = getMockContentResolver.insert(table.content_uri, cv);
//table.content_uri defined earlier
assertNotNull(uri);

but when I run the test, I found the trace showing:

INSERT INTO table.content_uri("key1","key2") VALUES(?,?);

I'm curious where did the values go. Anyone knows how to check the testing data?


Solution

  • Question marks are used as placeholders for SQLite queries in Android. The content values are substituted in automatically