No such table !!
See original GitHub issuehi 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:
- Created 7 years ago
- Reactions:6
- Comments:34
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
Clearly.
Check that your class child of Application extends from SugarApp or has inside the following lines
SugarContext.init(this);
not use getApplicationContext() insteadthis
Check that your Instant Run is disabled.
3 Check that your
DOMAIN_PACKAGE_NAME
set is correctly.Check that after changes (add lines on Application or disabling Instant Run) you remove app from your phone or clear app data.
Check that version of your bd >= 2 (as stated on the website of the author)
Trying Build->Clean Project->Rebuild Project after changes. It’s helped for me