I am using this code to save and restore my custom hand drawing view, how can I use this code to save my drawings in vector format, not bitmap, to a file on sdcard and reload it in next app session:
@Override
protected Parcelable onSaveInstanceState() {
// Get the superclass parcelable state
Parcelable superState = super.onSaveInstanceState();
if (mPoints.size() > 0) {// Currently doing a line, save it's current path
createHistoryPathFromPoints();
}
return new FreeDrawSavedState(superState, mPaths, mCanceledPaths,
mCurrentPaint, mPaintColor, mPaintAlpha, mResizeBehaviour,
mLastDimensionW, mLastDimensionH);
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
// If not instance of my state, let the superclass handle it
if (!(state instanceof FreeDrawSavedState)) {
super.onRestoreInstanceState(state);
return;
}
FreeDrawSavedState savedState = (FreeDrawSavedState) state;
// Superclass restore state
super.onRestoreInstanceState(savedState.getSuperState());
// My state restore
mPaths = savedState.getPaths();
mCanceledPaths = savedState.getCanceledPaths();
mCurrentPaint = savedState.getCurrentPaint();
initFillPaint();
mResizeBehaviour = savedState.getResizeBehaviour();
mPaintColor = savedState.getPaintColor();
mPaintAlpha = savedState.getPaintAlpha();
// Restore the last dimensions, so that in onSizeChanged i can calculate the
// height and width change factor and multiply every point x or y to it, so that if the
// View is resized, it adapt automatically it's points to the new width/height
mLastDimensionW = savedState.getLastDimensionW();
mLastDimensionH = savedState.getLastDimensionH();
notifyRedoUndoCountChanged();
}