Program: 87002
Project: 87002
Buggy source:
@Override public Uri insert(Uri uri,ContentValues values){
  SQLiteDatabase db=mEnvironmentDbHelper.getWritableDatabase();
  long _id;
  Uri returnUri;
switch (sUriMatcher.match(uri)) {
case GEOFENCE:
    _id=db.insert(GeoFenceEntry.TABLE_NAME,null,values);
  if (_id > 0) {
    returnUri=GeoFenceEntry.buildGeofenceUriWithId(_id);
  }
 else {
    Log.e(LOG_TAG,"String_Node_Str" + uri);
    throw new SQLiteException("String_Node_Str" + uri);
  }
break;
case ENVIRONMENT:
_id=db.insert(EnvironmentEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_GEOFENCES:
_id=insertEnvironmentLocation(uri,db,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case WIFI_NETWORK:
_id=db.insert(WiFiNetworksEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=WiFiNetworksEntry.buildWiFiUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_WIFI_NETWORKS:
_id=insertEnvironmentWifiNetwork(uri,db,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case BLUETOOTH_DEVICE:
_id=db.insert(BluetoothDevicesEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=BluetoothDevicesEntry.buildBluetoothUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_BLUETOOTH_DEVICES:
_id=insertEnvironmentBluetoothDevice(uri,db,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER:
_id=db.insert(UsersEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER_WITH_ID_AND_APP_WHITELIST:
String userIdString=uri.getPathSegments().get(1);
if (values.get(AppWhitelistEntry.COLUMN_USER_ID) == null) {
values.put(AppWhitelistEntry.COLUMN_USER_ID,userIdString);
}
_id=db.insert(AppWhitelistEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(Long.valueOf(userIdString));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER_WITH_ID_ENVIRONMENT_AND_PASSWORD:
_id=insertPassword(uri,db,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + uri);
}
getContext().getContentResolver().notifyChange(uri,null);
return returnUri;
}

Fixed version (ground truth):
@Override public Uri insert(Uri uri,ContentValues values){
  SQLiteDatabase db=mEnvironmentDbHelper.getWritableDatabase();
  long _id;
  Uri returnUri;
switch (sUriMatcher.match(uri)) {
case GEOFENCE:
    _id=db.insert(GeoFenceEntry.TABLE_NAME,null,values);
  if (_id > 0) {
    returnUri=GeoFenceEntry.buildGeofenceUriWithId(_id);
  }
 else {
    Log.e(LOG_TAG,"String_Node_Str" + uri);
    throw new SQLiteException("String_Node_Str" + uri);
  }
break;
case ENVIRONMENT:
_id=db.insert(EnvironmentEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_GEOFENCES:
_id=insertEnvironmentLocation(uri,db,values)[1];
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case WIFI_NETWORK:
_id=db.insert(WiFiNetworksEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=WiFiNetworksEntry.buildWiFiUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_WIFI_NETWORKS:
_id=insertEnvironmentWifiNetwork(uri,db,values)[1];
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case BLUETOOTH_DEVICE:
_id=db.insert(BluetoothDevicesEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=BluetoothDevicesEntry.buildBluetoothUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case ENVIRONMENT_WITH_ID_AND_BLUETOOTH_DEVICES:
_id=insertEnvironmentBluetoothDevice(uri,db,values);
if (_id > 0) {
returnUri=EnvironmentEntry.buildEnvironmentUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER:
_id=db.insert(UsersEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(_id);
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER_WITH_ID_AND_APP_WHITELIST:
String userIdString=uri.getPathSegments().get(1);
if (values.get(AppWhitelistEntry.COLUMN_USER_ID) == null) {
values.put(AppWhitelistEntry.COLUMN_USER_ID,userIdString);
}
_id=db.insert(AppWhitelistEntry.TABLE_NAME,null,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(Long.valueOf(userIdString));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
case USER_WITH_ID_ENVIRONMENT_AND_PASSWORD:
_id=insertPassword(uri,db,values);
if (_id > 0) {
returnUri=UsersEntry.buildUserUriWithId(Long.parseLong(uri.getPathSegments().get(1)));
}
 else {
Log.e(LOG_TAG,"String_Node_Str" + uri);
throw new SQLiteException("String_Node_Str" + uri);
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + uri);
}
getContext().getContentResolver().notifyChange(uri,null);
return returnUri;
}