0

I have an android application which need to be updated at code level and upgrade features. long story short the app useas a sqlite DB to store data but now it needs to store data in the cloud. is there an easy way to sync the sqlite stored data to firebase or remotemysql.com? (preferably firebase)

I have never used 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);
}

instead of rewrite the actual code I want to query data on the db acomodate into a json array and push into firebase with a button to "sync" data between local.db and firebase db

Kike_mskt
  • 45
  • 1
  • 6

1 Answers1

1

is there an easy way to sync the sqlite stored data to firebase or remotemysql.com? (preferably firebase)

There is not. If you're looking for a magic button that can convert your database from SQLite to the Firebase realtime Database, there isn't one! So unfortunately, you'll need to convert the database yourself.

instead of rewrite the actual code I want to query data on the db acomodate into a json array and push into firebase with a button to "sync"

You need to write code for that. So you should create your own mechanism to do that "sync" work.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193