question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hi i tried a lot to make sugar database work but it keeps returning NO SUCH TABLE error here is my code:

manifest: `<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="he.hrm.test48">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data android:name="DATABASE" android:value="shd.db" />
    <meta-data android:name="VERSION" android:value="1" />
    <meta-data android:name="QUERY_LOG" android:value="true" />
    <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="he.hrm.test48" />
</application>

</manifest>`

book class:

`public class Book extends SugarRecord { @Unique String isbn; String title; String edition;

// Default constructor is necessary for SugarRecord
public Book() {

}

public Book(String isbn, String title, String edition) {
    this.isbn = isbn;
    this.title = title;
    this.edition = edition;
}

}`

MainActivity

`public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SugarContext.init(getApplicationContext());
}

public void gogo(View view){
    Book book = new Book("bbeb","cecf","tegdt");
    book.save();
}

}`

it doesn’t work at all and the exception is “no such table: BOOK (code 1): , while compiling: INSERT OR REPLACE INTO BOOK(TITLE,ISBN,ID,EDITION) VALUES (?,?,?,?)”

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:34

github_iconTop GitHub Comments

8reactions
029vaibhavcommented, Aug 6, 2016
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="he.hrm.test48" />

This the package where you define your models for example if you define your models in he.hrm.test48.models/Book.java than “he.hrm.test48.models” should be your DOMAIN_PACKAGE_NAME

5reactions
whalemarecommented, Aug 7, 2019

Clearly.

  1. Check that your class child of Application extends from SugarApp or has inside the following lines SugarContext.init(this); not use getApplicationContext() instead this

  2. Check that your Instant Run is disabled.

3 Check that your DOMAIN_PACKAGE_NAME set is correctly.

  1. Check that after changes (add lines on Application or disabling Instant Run) you remove app from your phone or clear app data.

  2. Check that version of your bd >= 2 (as stated on the website of the author)

  3. Trying Build->Clean Project->Rebuild Project after changes. It’s helped for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - "no such table" exception - Stack Overflow
To fix this error just change "django.contrib.admin" in INSTALLED_APPS to "django.contrib.admin.apps.SimpleAdminConfig" , it will prevent "django.contrib.admin" ...
Read more >
error - no such table - Using Django
I'm trying to make an e-mail authorization and get an error when creating superuser. What's wrong? application 'www' models.py. from django.
Read more >
django.db.utils.OperationalError: no such table abc
OperationalError: no such table: myApp_tableStatus. The table tableStatus exists in my models.py. Any ideas what I can do to fix this ...
Read more >
SQLite 'no such table: json_each' error during notification check
Opened from the Prefect Public Slack Community niko: Hi, we just witnessed an error when running a prefect task locally on a windows...
Read more >
r/flask - sqlalchemy.exc.OperationalError: (sqlite3 ... - Reddit
The error is telling you exactly what the problem is, the table books does not exist. You have declared a model, but never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found