0

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);
                    }
                });
            }
        });
    }
Adam Gardner
  • 1,216
  • 1
  • 9
  • 21

1 Answers1

0

you can pull your db file if you are using a rooted device or emulator. Here is an example while using Eclipse. if you are on Android Studio, you can find DDMS from

Tools -> Android -> Android Device Monitor

Once you have your database file, you may view it in sqlitebrowser.

Community
  • 1
  • 1
Junaid Hafeez
  • 1,618
  • 1
  • 16
  • 25
  • Do this without rooting: **adb exec-out run-as `PKG` cat databases/`FILE` > `OUT`** where PKG is the package name of your app, FILE is the name of the database file (the same name you used in your SQLiteOpenHelper subclass) and OUT is the output name of your file on the connected computer. Then as junaid says, you can review the database file with an SQLite database reader – atwrk Jan 20 '17 at 21:16