0

I am developing a new module in an existing android project. The existing project is already having a database with some tables. In the new module I need a new table called Audio. In future I may use this module in some other apps(which would be already having database) too. What is the better approach to get a table Audio?

Prabhu M
  • 3,534
  • 8
  • 48
  • 87

1 Answers1

0

Create a separate class and implement your queries and operations there.

public static final String newTabQuery = "CREATE TABLE IF NOT EXISTS " + MY_TABLE
        + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)";

You can create generic methods for different database operations

 public void insertData(SQLiteOpenHelper helper, Data queryValues) {

        SQLiteDatabase database = helper.getWritableDatabase();
        ContentValues values = new ContentValues();

        values.put("id", queryValues.getId());
        values.put("name", queryValues.getName());

        database.insert(DATA_TRACKING_TABLE, null, values);
        database.close();
    }
Kunu
  • 5,078
  • 6
  • 33
  • 61