ФАТАЛЬНОЕ ИСКЛЮЧЕНИЕ на SugarRecord из Cloud Firebase - PullRequest
0 голосов
/ 18 декабря 2018

В моем Android проекте я использую SugarRecord для локального хранения коллекции Cloud Firestore .

Когда я запускаю кодЯ получаю следующее ФАТАЛЬНОЕ ИСКЛЮЧЕНИЕ.Я не знаю, почему он пытается скомпилировать INSERT OR REPLACE INTO STORE(TOTAL_TEXT,ADDRESS,MAIL,TOTAL_XPOINT,PHONE,CURRENCY,CITY,OWNER,DATE_FORMAT,ID,NAME,PRICE_SEPARATOR,POSTAL_CODE,TAX_CODE,STORE_ID,COUNTRY) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?).

Откуда этот код SQL?Я этого не писал.

Как я могу исправить эту ошибку?Уже 3 недели я слежу за этой проблемой.

Store.java

public class Store extends SugarRecord
{
    @Unique
    private String storeId;
    private String address;
    private String city;
    private String country;
    private String mail;
    private String phone;
    private String postalCode;
    private String taxCode;
    private String name;
    private float totalXpoint;
    private String priceSeparator;
    private String totalText;
    private String dateFormat;
    private String currency;

    public Store()
    {
        super();
    }

    public String getOwner()
    {
        return owner;
    }

    public void setOwner(String owner)
    {
        this.owner = owner;
    }

    private String owner;


    public String getStoreId()
    {
        return storeId;
    }

    public void setStoreId(String storeId)
    {
        this.storeId = storeId;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getCity()
    {
        return city;
    }

    public void setCity(String city)
    {
        this.city = city;
    }

    public String getCountry()
    {
        return country;
    }

    public void setCountry(String country)
    {
        this.country = country;
    }

    public String getMail()
    {
        return mail;
    }

    public void setMail(String mail)
    {
        this.mail = mail;
    }

    public String getPhone()
    {
        return phone;
    }

    public void setPhone(String phone)
    {
        this.phone = phone;
    }

    public String getPostalCode()
    {
        return postalCode;
    }

    public void setPostalCode(String postalCode)
    {
        this.postalCode = postalCode;
    }

    public String getTaxCode()
    {
        return taxCode;
    }

    public void setTaxCode(String taxCode)
    {
        this.taxCode = taxCode;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public float getTotalXpoint()
    {
        return totalXpoint;
    }

    public void setTotalXpoint(float totalXpoint)
    {
        this.totalXpoint = totalXpoint;
    }

    public String getPriceSeparator()
    {
        return priceSeparator;
    }

    public void setPriceSeparator(String priceSeparator)
    {
        this.priceSeparator = priceSeparator;
    }

    public String getTotalText()
    {
        return totalText;
    }

    public void setTotalText(String totalText)
    {
        this.totalText = totalText;
    }

    public String getDateFormat()
    {
        return dateFormat;
    }

    public void setDateFormat(String dateFormat)
    {
        this.dateFormat = dateFormat;
    }

    public String getCurrency()
    {
        return currency;
    }

    public void setCurrency(String currency)
    {
        this.currency = currency;
    }

    @Override
    public String toString()
    {
        return "Store{" +
                "storeId='" + storeId + '\'' +
                ", address='" + address + '\'' +
                ", city='" + city + '\'' +
                ", country='" + country + '\'' +
                ", mail='" + mail + '\'' +
                ", phone='" + phone + '\'' +
                ", postalCode='" + postalCode + '\'' +
                ", taxCode='" + taxCode + '\'' +
                ", name='" + name + '\'' +
                ", totalXpoint=" + totalXpoint +
                ", priceSeparator='" + priceSeparator + '\'' +
                ", totalText='" + totalText + '\'' +
                ", dateFormat='" + dateFormat + '\'' +
                ", currency='" + currency + '\'' +
                '}';
    }
}

FirebaseDatabaseHelper.java

public static void getAllStores(final StoresSyncedListener storesSyncedListener)
    {
        FirebaseFirestore db = FirebaseFirestore.getInstance();
        log("getAllStores");
        db.collection("Stores")
                .get()
                .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
                {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task)
                    {
                        log("task.toString " + task.toString());
                        log("task.isSuccessful " + task.isSuccessful());
                        if (task.isSuccessful())
                        {
                            log("task.getResult " + task.getResult().size());
                            for (QueryDocumentSnapshot document : task.getResult())
                            {
                                Store store = document.toObject(Store.class);
                                store.setStoreId(document.getId());
                                //save all stores to local Sugar database
                                SugarRecord.save(store);
                            }
                            log("task.SugarRecord.saveInTx B");

                            storesSyncedListener.onStoresSynced(true);
                        }
                        else
                        {
                            storesSyncedListener.onStoresSynced(false);
                            logError("Error getting documents: ", task.getException());
                        }
                    }
                });
    }

Logcat

12-17 22:29:47.852 9224-9224/juca.invoiceocrreader E/AndroidRuntime: FATAL EXCEPTION: main
    Process: juca.invoiceocrreader, PID: 9224
    android.database.sqlite.SQLiteException: no such table: STORE (code 1): , while compiling: INSERT OR REPLACE  INTO STORE(TOTAL_TEXT,ADDRESS,MAIL,TOTAL_XPOINT,PHONE,CURRENCY,CITY,OWNER,DATE_FORMAT,ID,NAME,PRICE_SEPARATOR,POSTAL_CODE,TAX_CODE,STORE_ID,COUNTRY) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
        at com.orm.SugarRecord.save(SugarRecord.java:280)
        at com.orm.SugarRecord.save(SugarRecord.java:260)
        at juca.invoiceocrreader.firebase.FirebaseDatabaseHelper$2.onComplete(FirebaseDatabaseHelper.java:133)
        at com.google.android.gms.tasks.zzj.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:746)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5443)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...