更新后删除数据

时间:2018-09-18 10:21:46

标签: android updates auto-update

我已经为我的应用发布了一个新的更新,但是当我从Play商店升级它时,我看到应用数据已删除。为什么? 谢谢

我的清单:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

1 个答案:

答案 0 :(得分:0)

如果您使用Sqlite,并且在代码中将表放在onUpgrade中,则可能会发生这种情况!

@Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

      db.execSQL("DROP TABLE IF EXISTS '" + DATABASE_TABLE + "'");

}