我有一个需要在代码级别更新和升级功能的 android 应用程序。长话短说,该应用程序用作 sqlite DB 来存储数据,但现在它需要将数据存储在云中。有没有一种简单的方法可以将 sqlite 存储的数据同步到 firebase 或 remotemysql.com?(最好是火力基地)
我从来没有用过sqlite
class FoodDBOpenHelper extends SQLiteOpenHelper {
//specify the database local file name
private static final String DATABASE_NAME = "foods.db";
private static final int DATABASE_VERSION = 3;
public FoodDBOpenHelper(Context context) {
super(context, DATABASE_NAME, null , DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
final String SQL_CREATE_TUTORIALS_TABLE = "CREATE TABLE " +
FoodContract.FoodEntry.TABLE_NAME + " (" +
FoodContract.FoodEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
FoodContract.FoodEntry.COLUMN_FOOD_NAME+ " TEXT NOT NULL," +
FoodContract.FoodEntry.COLUMN_FOOD_UNIT + " INTEGER NOT NULL," +
FoodContract.FoodEntry.COLUMN_FOOD_QUANTITY + " REAL NOT NULL," +
FoodContract.FoodEntry.COLUMN_FOOD_CATEGORY + " INTEGER NOT NULL," +
FoodContract.FoodEntry.COLUMN_FOOD_REGISTERED_TIMESTAMP + " TEXT NOT NULL," +
FoodContract.FoodEntry.COLUMN_FOOD_EXPIRE_DATE + " TEXT NOT NULL," +
FoodContract.FoodEntry.COLUMN_SECTION_ID + " INTEGER NOT NULL" +
");";
sqLiteDatabase.execSQL(SQL_CREATE_TUTORIALS_TABLE);
}
而不是重写实际代码,我想将 db acomodate 上的数据查询到一个 json 数组中,并使用一个按钮推入 firebase,以在 local.db 和 firebase db 之间“同步”数据