在Play商店下载Android推送更新 [英] Android Pushing Updates on Play Store

查看:118
本文介绍了在Play商店下载Android推送更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有依赖于SQLite,让它是由附带的资产文件夹中的应用XML的数据填充的应用程序。

I have an app that depends on SQLite for data which is populated by xmls shipped with the app in the assets folder.


  1. 当你运行应用程序在第一次设置一个共享preference config_run =假。

  2. 然后我检查config_run =假然后解析XML和数据转储到数据库

  3. 设置config_run = TRUE

现在我意识到,当我要推谷歌更新播放,并添加更多的内容到XML。虽然我从1数据库版本更改为2导入脚本不会运行,因为共享preference config_run值将被设置为true。

Now i realize that when i have to push an update on Google Play and add more content into the XML. Even though i change the database version from 1 to 2. The import script wont run because shared preference config_run value will be set to true.

有关如何处理这种情况的任何指针?

Any pointers on how to handle this situation ?

场景


  1. 首先INSTAL - 版本= 1,DB V = 1(数据被解析并倾倒到数据库)

  2. 修复的错误和推送和更新,但没有数据发生了变化 - 版本= 1.1,DB V = 1(它应该只是更换code和不升级或重新创建数据库)

  3. 升级的数据,并推动新的更新 - 1.2版本,DB = 2(无新的code,但数据重新创建)

我的应用程序的流量


  1. 应用程序启动时飞溅的活动。如果共享preF - config_run等于虚假然后开始一个进度对话框并解析和数据转储到数据库中。

  2. 当解析和创建数据库,并为之倾倒去MainActivity数据。

第二个案例


  1. SplashActivity道和config_run = true,以便直接进入主要活动。

的建议由少数人以下,如果我尝试哑数据到在SQLiteHelper的onUpgrade数据库只会在MAinActivity因为我不开了SplashActivity一个数据库连接和对话的进展不会被同时显示发生。

As Suggested by few people below if i try to dumb the data into the database in onUpgrade of the SQLiteHelper it will happen only in MAinActivity as i dont open a Db connection in the SplashActivity and the Dialog Progress wont be displayed also.

推荐答案

而不是你的共享preF(config_run)设置为false,使之真正的,刚才设置的数据库版本到它的。当您更新您的应用程序,检查是否有您的共享$ P $粉煤相同的版本号。你可以做到这一点,如下所示:

Instead of setting your shared pref (config_run) to false and making it true, just set the database version into it. When you update your app, check whether you have the same version number in your shared pref. You can do this as shown below:

configRun = settings.getInt("database_version", 0);

if ((DBAdapter.DATABASE_VERSION) == configRun) 
{
//skip xml parsing
}
else
{
//first time configRun will be "0" and DBAdapter.DATABASE_VERSION will be 1
// so you need to parse your xml here and set configRun =1
//on update, change your DB version to 2. now again your configRun and DBAdapter.DATABASE_VERSION will mismatch and you can parse your xml.
}

这篇关于在Play商店下载Android推送更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆