I am working on sqlite in my android app.
I am asking this ridiculous question but effective.
- Can anyone copy my Database stored in the internal storage?
- How secure is the sdcard to make a database?
Second question: Not very secure. Use the internal storage if you can, it's a lot more secure. Any program can edit anything on the sd card, so all someone would have to do is plop the card into their computer, mount the sqlite database, and they would have full access to the database, including read/write/edit.
Internal storage is secure, in theory, however, if a person has a rooted device, they might be able to get into even that. However, that won't be very many people, you just need to keep an eye out for it.
If you really have to find a secure solution against every attempt, you might look into encrypted databases.
First question: Sure, you can copy the database, just like you would copy any file.
You can copy the database to sdcard, but it will not be secure. Any application or external device reading the SD card, can access it.
Anyone with access to a SD is technically capable of copying your sqlite file. I don't think the internal storage is secure enough (since you can root a device and have administration access, you can do virtually everything there). Anyway, here's a link on how to copy your sqlite file to the internal storage
You have to send your database to a server after some time because SD card not secure enough. And below the code for copying a whole DB folder.
public static void copyDirectoryOneLocationToAnotherLocation(File sourceLocation, File targetLocation)
throws IOException {
if (sourceLocation.isDirectory()) {
if (!targetLocation.exists()) {
targetLocation.mkdir();
}
String[] children = sourceLocation.list();
for (int i = 0; i < sourceLocation.listFiles().length; i++) {
copyDirectoryOneLocationToAnotherLocation(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
}
} else {
InputStream in = new FileInputStream(sourceLocation);
OutputStream out = new FileOutputStream(targetLocation);
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}