I know there are many topic that have the same title, but I've tried all of them. I couldn't solve my problem.
The error I get is exactly this:
android.database.sqlite.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.halilkaya.flashcard/databases/flashcarddb.db
Actually, it works on the emulator, but when I install it on my phone, it doesn't work!
我知道有很多主题都有相同的标题,但我已经尝试了所有这些主题。我无法解决我的问题。我得到的错误就是这样:android.database.sqlite.SQLiteException:无法将只读数据库从版本0升级到1:/data/data/com.halilkaya.flashcard/databases/flashcarddb.db实际上,它的工作原理在模拟器上,但当我在手机上安装它时,它不起作用!
3 个解决方案
#1
4
Hope you are dropping the table and upgrading it aagain as below
希望你正在放弃桌子并升级它如下所示
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + LOCATION_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + PHONE_TABLE);
// Create tables again
onCreate(db);
}
#2
0
When I hit this there was another sql exception earlier in the logcat (my HTC OneX test phone likes to hide crashes and make me go looking for them instead of just crashing). I had a malformed statement in my upgrade logic. Once I cleared that up I no longer got the "can't upgrade read-only database" error.
当我点击这个时,logcat中的另一个sql异常(我的HTC OneX测试手机喜欢隐藏崩溃并让我去寻找它们而不仅仅是崩溃)。我的升级逻辑中有一个格式错误的语句。一旦我清除了它,我就不再有“无法升级只读数据库”的错误。
#3
0
this is a class that is started from an onclick button using an intent.
这是一个使用intent从onclick按钮启动的类。
public class disp_emails_sent extends Activity
......
protected void onCreate(Bundle bd)
{
super.onCreate(bd);
setContentView(R.layout.disp_db_res);
lv = (ListView) findViewById(R.id.myEmail_list);
List<String> arrayL = new ArrayList<String>();
db_handler dbHand = new db_handler(disp_emails_sent.this);
(disp_emails_sent.this) shown above is usually where you would pass your context. this.getApplicationContext() didnt work for me but this did.
上面显示的(disp_emails_sent.this)通常是您传递上下文的位置。 this.getApplicationContext()对我没有用,但确实如此。
Not sure how it worked but it did.
不确定它是如何工作但它确实如此。
Did try the above answers provided by the community but this wasnt the issue.
尝试过社区提供的上述答案,但这不是问题。
Would like an explanation if anyone has it.
想要解释,如果有人拥有它。
#1
4
Hope you are dropping the table and upgrading it aagain as below
希望你正在放弃桌子并升级它如下所示
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + LOCATION_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + PHONE_TABLE);
// Create tables again
onCreate(db);
}
#2
0
When I hit this there was another sql exception earlier in the logcat (my HTC OneX test phone likes to hide crashes and make me go looking for them instead of just crashing). I had a malformed statement in my upgrade logic. Once I cleared that up I no longer got the "can't upgrade read-only database" error.
当我点击这个时,logcat中的另一个sql异常(我的HTC OneX测试手机喜欢隐藏崩溃并让我去寻找它们而不仅仅是崩溃)。我的升级逻辑中有一个格式错误的语句。一旦我清除了它,我就不再有“无法升级只读数据库”的错误。
#3
0
this is a class that is started from an onclick button using an intent.
这是一个使用intent从onclick按钮启动的类。
public class disp_emails_sent extends Activity
......
protected void onCreate(Bundle bd)
{
super.onCreate(bd);
setContentView(R.layout.disp_db_res);
lv = (ListView) findViewById(R.id.myEmail_list);
List<String> arrayL = new ArrayList<String>();
db_handler dbHand = new db_handler(disp_emails_sent.this);
(disp_emails_sent.this) shown above is usually where you would pass your context. this.getApplicationContext() didnt work for me but this did.
上面显示的(disp_emails_sent.this)通常是您传递上下文的位置。 this.getApplicationContext()对我没有用,但确实如此。
Not sure how it worked but it did.
不确定它是如何工作但它确实如此。
Did try the above answers provided by the community but this wasnt the issue.
尝试过社区提供的上述答案,但这不是问题。
Would like an explanation if anyone has it.
想要解释,如果有人拥有它。