Code example for JsonWriter

Methods: beginArraycloseendArrayflush

0
                    if (mJsonWriter == null) return null;
                    // TODO: This is necessary to avoid an exception.  Better would be to not even 
                    // open the JsonWriter if the file is not even opened unless there is valid data 
                    // to write. 
                    if (!mHasWrittenData) {
                        mJsonWriter.beginArray();
                    } 
                    mJsonWriter.endArray();
                    mHasWrittenData = false;
                    mJsonWriter.flush();
                    mJsonWriter.close();
                    if (DEBUG) {
                        Log.d(TAG, "closed " + mFile);
                    } 
                } catch (final Exception e) {
                    Log.d(TAG, "error when closing ResearchLog:", e);
                } finally { 
                    // Marking the file as read-only signals that this log file is ready to be 
                    // uploaded. 
                    if (mFile != null && mFile.exists()) {