use of com.amitshekhar.model.RowDataRequest in project Android-Debug-Database by amitshekhariitbhu.
the class RequestHandler method addTableDataAndGetResponse.
private String addTableDataAndGetResponse(String route) {
UpdateRowResponse response;
try {
Uri uri = Uri.parse(URLDecoder.decode(route, "UTF-8"));
String tableName = uri.getQueryParameter("tableName");
String updatedData = uri.getQueryParameter("addData");
List<RowDataRequest> rowDataRequests = mGson.fromJson(updatedData, new TypeToken<List<RowDataRequest>>() {
}.getType());
if (Constants.APP_SHARED_PREFERENCES.equals(mSelectedDatabase)) {
response = PrefHelper.addOrUpdateRow(mContext, tableName, rowDataRequests);
} else {
response = DatabaseHelper.addRow(sqLiteDB, tableName, rowDataRequests);
}
return mGson.toJson(response);
} catch (Exception e) {
e.printStackTrace();
response = new UpdateRowResponse();
response.isSuccessful = false;
return mGson.toJson(response);
}
}
Aggregations