I am trying to let users import and export their sqlite database from the data/data directory through various means e.g. email, onedrive, google drive, internal and external storage etc. I am not quite sure how to do this. I have the following code at the moment which saves it to their SD card. I am not sure how to move from here.
public static void export() throws IOException {
//Open your local db as the input stream
String inFileName = "/data/data/com.example.main/databases/myDB";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = Environment.getExternalStorageDirectory()+"/myDB";
//Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
output.write(buffer, 0, length);
}
//Close the streams
output.flush();
output.close();
fis.close();
}
Could someone please help me out and show me how to export the SQLite database using email, onedrive etc. whatable capable medium the user has on their device.