My application creates a db, what I want to do is a backup of what it contains then I do the following code:
File CarFile = new File("sdcard/xxxx");
if (!CarFile.exists()) {
try {
CarFile.mkdir();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
File f=new File("/data/data/x.x.x/databases/xxx.db");
FileInputStream fis=null;
FileOutputStream fos=null;
try
{
fis=new FileInputStream(f);
fos=new FileOutputStream("sdcard/xxxx/xxx.sql");
while(true)
{
int i=fis.read();
if(i!=-1)
{fos.write(i);}
else
{break;}
}
fos.flush();
Toast.makeText(this, "OK", Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
e.printStackTrace();
Toast.makeText(this, "ERROR", Toast.LENGTH_LONG).show();
}
finally
{
try
{
fos.close();
fis.close();
}
catch(IOException ioe)
{}
}
but the code I get is not readable in a text editor and no sqlite manager.