Как сделать файл скрытым в SD-карте андроида?

Можно также считать классы контракта реализованными с NVI (Не Виртуальный Интерфейсный Шаблон). Например:

struct Contract1 : boost::noncopyable
{
    virtual ~Contract1();
    void f(Parameters p) {
        assert(checkFPreconditions(p)&&"Contract1::f, pre-condition failure");
        // + class invariants.
        do_f(p);
        // Check post-conditions + class invariants.
    }
private:
    virtual void do_f(Parameters p) = 0;
};
...
class Concrete : public Contract1, public Contract2
{
private:
    virtual void do_f(Parameters p); // From contract 1.
    virtual void do_g(Parameters p); // From contract 2.
};
9
задан Ravi 8 July 2016 в 13:18
поделиться

3 ответа

Any file stored on the SD card is accessible both by applications running on the phone, and by users who have mounted the SD card (both while it's in the phone and otherwise).

You can change the file properties to make it 'hidden', but it will still be easily found. There is no way to make a file on a public partition like an SD Card 'secure' in the manner you describe - users will always be able to copy, delete, and potentially change the file.

The best solution to your problem is to look into ways to encrypt your database to record it securely. You won't be able to prevent users from deleting or copying the file, but you should be able to make it difficult for them to read data from it or modify its contents.

11
ответ дан 4 December 2019 в 08:34
поделиться

Для простого решения просто добавьте к файлу db префикс. (например, .dbfile). Это скроет файл в системах на базе Linux, включая android.

Я предполагаю, что вы хотите скрыть файл, чтобы пользователи не могли случайно удалить / изменить его.

7
ответ дан 4 December 2019 в 08:34
поделиться

SD cards cannot be secured in the fashion you seek.

3
ответ дан 4 December 2019 в 08:34
поделиться
Другие вопросы по тегам:

Похожие вопросы: