0

I am working on sqlite in my android app.

I am asking this ridiculous question but effective.

  1. Can anyone copy my Database stored in the internal storage?
  2. How secure is the sdcard to make a database?
Charles
  • 50,943
  • 13
  • 104
  • 142
Monty
  • 3,205
  • 8
  • 36
  • 61

4 Answers4

0

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.

PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
  • what i m saying is ..any other user can stole my data if it is inside internal memory...any possibility by programatically – Monty Feb 01 '13 at 11:52
  • @CobraHissssHissss.....: Just edited my question, but as Shiv mentioned, if the user has root access, they can still edit your database... – PearsonArtPhoto Feb 01 '13 at 11:56
  • what do you mean by root access shiv. and is it achievable programatically – Monty Feb 01 '13 at 12:05
  • @CobraHissssHissss.....: Essentially, someone has to "root" their device to get that kind of info. Rooting allows for the removal of security, essentially allowing the user to do whatever they want to the device. If someone really wants it, however, they can probably get your data, but the average consumer won't be able to. – PearsonArtPhoto Feb 01 '13 at 12:06
  • is there any way to protect that. – Monty Feb 01 '13 at 12:14
  • Encypted databases offer the best protection. I've seen them run for Android for around $300 USD. – PearsonArtPhoto Feb 01 '13 at 13:02
0

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.

Gjordis
  • 2,540
  • 1
  • 22
  • 32
0

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

Community
  • 1
  • 1
Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
0

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();
    }

}
Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93
duggu
  • 37,851
  • 12
  • 116
  • 113
  • You still have a sqlite copy into the SD, so it is still accessed. I see your answer as a one-way backup system (yet rudimentary, useful to start coding with) – Sergi Juanola Feb 01 '13 at 12:03
  • this the code for copy your database into SD card only but this is not a good way so you have to send your database backup to server for copy(or backup) – duggu Feb 01 '13 at 12:08
  • But the OP is claiming if an sqlite file can be compromised by others. with access to the storage/SD. If I am not mistaken, he wants to know if anyone can see what's inside his own database, not saving it in case of corruption (which is cool, too) – Sergi Juanola Feb 01 '13 at 12:11