0

Пробую использовать готовую базу данных с SugarORM, копирую DB в нужную папку getApplicationContext().getDatabasePath("data.db").getPath(). Заполняю все как надо в манифесте , ORM вроде видит DB но не читает содержимое, а выдает table TABLE already exist, таблицы созданы и именованы правильно, не пойму что дальше делать Руководствовался этим ответом

Копирую вот так:

InputStream myInput = getApplicationContext().getAssets().open("data.db");
     OutputStream myOutput = new FileOutputStream(getApplicationContext().getDatabasePath("data.db").getPath());
     byte[] buffer = new byte[1024];
     int length;
     while ((length = myInput.read(buffer)) > 0) {
         myOutput.write(buffer, 0, length);
     }
     myOutput.flush();
     myOutput.close();
     myInput.close();

AndroidManifest:

<meta-data
        android:name="DATABASE"
        android:value="data.db" />
    <meta-data
        android:name="VERSION"
        android:value="1" />
    <meta-data
        android:name="QUERY_LOG"
        android:value="true" />

1 ответ 1

0

В документации по SugarORM сказано, что версия, прописааная в манифесте не может быть меньше 2х. Вероятно в этом ваша проблема.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.