1

I am using Library greendao to save the data type to local database. After setting up the entity and running the app a new property was added in the api response. It became something like this. before :

@Entity
public class Data{
    @Id
    long id;
    String name;
    String detail;
}

after:

@Entity
public class Data{
    @Id
    long id;
    String name;
    String detail;
    String image;
  }

After updating data type I reinstalled the app then ran the app but there was an error android.database.sqlite.SQLiteException: no such column: T.IMAGE (code 1): , while compiling: SELECT T."_id",T."NAME",T."DETAIL",T."IMAGE" FROM "DATA" T

How do I solve this?

SarojMjn
  • 569
  • 1
  • 7
  • 23
  • Can you access the db via sqlite command line tool and provide the `.schema`, or better the `.dump` ? Feel free to create a [mcve] without any classified or personal data, as long as it has the same issue. – Yunnosch Apr 25 '17 at 06:27
  • I have a similar problem. Maybe, this answer help you. https://stackoverflow.com/a/44527501/5286400 – VIX Jun 13 '17 at 17:04
  • I have a similar problem. Maybe, this answer help you. https://stackoverflow.com/a/44527501/5286400 – VIX Jun 13 '17 at 17:06

2 Answers2

8

After searching for few hours I found the answer. The answer is to increase the schemaversion in build.gradle file.

greendao { schemaVersion 1 }

to

greendao { schemaVersion 2 }

Then rebuild app and reinstall.

SarojMjn
  • 569
  • 1
  • 7
  • 23
0

@Saroj please locate where your database was created. Whether you had created in the internal cache directory or in external sdcard.Seeing your above issue it seems its in external sdcard. The path would be probably mnt/sdcard/data and try locate your db using fileExplorer of Android Studio or using Explorer if you are using device. Delete that database and app and then reinstall the app

Aditi
  • 389
  • 4
  • 13