The answer applies to both your SQLite dbase file and to your Shared Prefs.
First, turn anything you want to save into byte[] buffer. Here is an example for SQLite dbase:
byte[] getDBBytes() {
Context ctx = getApplicationContext();
byte[] out = null;
try {
File from = ctx.getDatabasePath(ctx.getString(R.string.app_name));
if (from.exists())
out = strm2Bytes(new FileInputStream(from));
} catch (Exception e) {}
return out;
}
(strm2Bytes() is a primitive that copies file to byte[] buffer).
Then use the DEMO ('Create a file in a folder', 'Edit contents') to put the data in a Drive file. Keep these two processes separate, since you'll be only updating contents if the file exists.
To get it back, start with 'Retrieve contents' just replace the BufferBuilder, StringBuilder with your own InputStream reader that produces the data you place back into your SQLite file. Something similar to :
public static void setDB(InputStream is) {
Context ctx = getApplicationContext();
try {
File to = ctx.getDatabasePath(ctx.getString(R.string.app_name));
if (to.exists())
to.delete();
strm2File(is, to);
} catch (Exception e) {}
}
(again, strm2FIle() is a primitive that copies stream into a file)
Sorry, I'm giving you only high level ideas, I tried to pull functional snippets from my code, but it is so tangled that I would have to copy half of my stuff here.