0

As a part of Unit testing I wanted to insert values to DB using content resolver. But when I tried this,

 @Before
    public void runBeforeTestSignOut() {
        ContentValues values = new ContentValues();
        String userId="123";
        String userInfo="test";
        values.put(UserProvider.USER_ID, userId);
        values.put(UserProvider.USER_INFO, userInfo);
        System.out.print("Values are "+values);
        Uri uri = contentResolver.insert(UserProvider.CONTENT_USER_URI, values);
    }

Values are still assigned null. I can’t figure out why this is happening. I found some related questions but couldn’t find a solution. Please help me with this.

Subin T
  • 157
  • 1
  • 1
  • 11
  • I assumed `UserProvider.USER_ID = "user_id"` and `UserProvider.USER_INFO = "user_info"`. And checked your code, It's working fine. Check [this](http://prntscr.com/m5de0v) screenshot. – Ajay Mehta Jan 10 '19 at 13:17
  • @Ajay-Rlogical Yes but for me its not working. Cant figure out what is the issue here. – Subin T Jan 10 '19 at 16:28

0 Answers0