I have a DatabaseHandler class and am saving my parsed XML to the database. Well, I hope I am. I am not sure how to see what is in the database and see if it is saving correctly so I can pull some of the data out and do more development. I have tried a log statement but all I get is my package name and some random string of numbers.
I'm creating the table and adding the parsed data in the onResponse as I want to save this as soon as the parsing is done as the web service is slow.
public void getXMLData() {
OkHttpClient client = getUnsafeOkHttpClient();
Request request = new Request.Builder()
.url(getString(R.string.API_FULL_URL))
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
final String responseData = response.body().string();
final InputStream stream = new ByteArrayInputStream(responseData.getBytes());
final XMLPullParserHandler parserHandler = new XMLPullParserHandler();
final ArrayList<Employee> employees = (ArrayList<Employee>) parserHandler.parse(stream);
employeeModel = new Employee();
mEmployees.clear();
mEmployees.addAll(employees);
DatabaseHandler databasehandler = new DatabaseHandler(getApplicationContext());
db = databasehandler.getWritableDatabase();
databasehandler.onCreate(db);
databasehandler.addEmployee(employeeModel);
//tell adapter on the UI thread its data changed
runOnUiThread(new Runnable() {
@Override
public void run() {
mTopListViewAdapter.notifyDataSetChanged();
mBottomListViewAdapter.notifyDataSetChanged();
mMangerList.setVisibility(View.VISIBLE);
directReportListView.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.GONE);
}
});
}
});
}