SQLiteException: no such table:
See original GitHub issueHello I have been encountering this issue both on the emulator and on my physical Nexus 5. My code works as follow:
-
the fragment calls this line in onCreateView
if(FavoriteUtils.checkIfThisIsFavorite(mShow))
-
then this method gets executed
public static boolean checkIfThisIsFavorite(Show s){
List<Show> results = getListFromDb(s, WHERE_CLAUSE_ID);
if(results.size() > 0){
//found match
return true;
}else {
//no match
return false;
}
}
- Then finally this
private static List<Show> getListFromDb(Show s, String whereClause){
int showId = s.getShowId();
return Select.from(Show.class)
.where(Condition.prop(whereClause)
.eq(Integer.valueOf(showId)
.toString()))
.list(); // Line of crash
}
This is the version of sugar ORM I’m using compile 'com.github.satyan:sugar:1.4'
.
This is my manifest’s application tag.
<application
android:name="com.orm.SugarApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="DATABASE" android:value="fav.db" />
<meta-data android:name="VERSION" android:value="2" />
//I manually removed the other two tags just to be sure, no difference
...
</application>
And this is my model class:
public class Show extends SugarRecord {
int showId;
String title; // original_title
String image; // poster_path
String image2; // backdrop_path used in DetailActivity
String overview;
int rating; // vote_average
String date; // release_date
public Show() {
}
public Show(JSONObject movie) throws JSONException {
this.showId = movie.getInt("id");
this.title = movie.getString("original_title");
this.image = movie.getString("poster_path");
this.image2 = movie.getString("backdrop_path");
this.overview = movie.getString("overview");
this.rating = movie.getInt("vote_average");
this.date = movie.getString("release_date");
}
public Show(JSONObject movie, int notNeeded) throws JSONException {
this.showId = movie.getInt("id");
this.title = movie.getString("original_name");
this.image = movie.getString("poster_path");
this.image2 = movie.getString("backdrop_path");
this.overview = movie.getString("overview");
this.rating = movie.getInt("vote_average");
this.date = movie.getString("first_air_date");
}
public int getShowId() {
return showId;
}
public String getTitle() {
return title;
}
public String getImage() {
return "http://image.tmdb.org/t/p/w185" + image;
}
public String getImage2() {
return "http://image.tmdb.org/t/p/w300" + image2;
}
public String getOverview() {
return overview;
}
public int getRating() {
return rating;
}
public String getDate() {
return date;
}
}
Stacktrace:
9-15 18:41:59.507 6307-6307/com.dcs.shows E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dcs.shows, PID: 6307
android.database.sqlite.SQLiteException: no such table: SHOW (code 1): , while compiling: SELECT * FROM SHOW WHERE (SHOW_ID = ? )
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.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1240)
at com.orm.SugarRecord.find(SugarRecord.java:192)
at com.orm.query.Select.list(Select.java:118)
at com.dcs.shows.utils.FavoriteUtils.getListFromDb(FavoriteUtils.java:38)
at com.dcs.shows.utils.FavoriteUtils.checkIfThisIsFavorite(FavoriteUtils.java:23)
at com.dcs.shows.DetailFragment.onCreateView(DetailFragment.java:83)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:15
Top Results From Across the Web
SQLiteException: no such table - android - Stack Overflow
sqlite.SQLiteException: no such table: exhibitor: , while compiling: SELECT _id, EXHIBITOR FROM exhibitor ORDER BY EXHIBITOR but when I check ...
Read more >[Developer Preview Android P] SQLiteException: no such ...
SQLiteException : no such table: StateProvinceDB (code 1 SQLITE_ERROR): , while compiling: SELECT DISTINCT [StateProvName] from StateProvinceDB where ...
Read more >android.database.sqlite.SQLiteException: no such table ... - B4X
I'm new to B4A and android. In fact I'm building my first test app. I followed this tutorial: and attempted to create my...
Read more >Caused by android database sqlite SQLiteException no such ...
sqlite.SQLiteException: no such table generalSettings (code 1): pick * from generalSettings error during compilation. My SQLite helper class to ...
Read more >SqliteException: no such table · Issue #493 · simolus3/drift
I am stuck with this error: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SqliteException: no such table: my_entries I ...
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
@fermatijoe,
![image](https://user-images.githubusercontent.com/8195419/30238118-7c97b0f0-9549-11e7-85f4-c9c490ca7c30.png)
Example my domain of class package is db all SugarRecords objects here. Please look my previous message, link contains all details.
@ayebaretony , firstly close Instant Run than add prog-guard rule. I explained here: https://mehmethanoglu.com.tr/tips/15-activedroid-ve-sugarorm-1.5-android-studio-2.2-kullanimi.html