是否有一个类(类似于contentProvider)与jdbc或其他数据库进行交互?

时间:2018-12-19 07:57:13

标签: java android postgresql android-contentprovider

我目前正在使用contentProvider与Android中的SQLite数据库一起使用。同时,我正在使用在线Postgresql数据库。

我想知道是否可以使用与本地数据库进行交互的类似方法。

我目前使它通用的方法是传递一个表名,以便代码可以与数据库中的不同表一起使用并根据该表采取特定的操作:

public static LinkedList<Value> sendToServer(String tableName, LinkedList<Value> values) {
    LinkedList<Values> successfullySentValues = new LinkedList<>();
    switch (tableName) {
        case "tableOne":
            //Do whatever needs to be done in case of tableOne
            //Add the Values that are successfully sent to the database to successfullySentValues
            break;
        case "tableTwo":
            //Do whatever needs to be done in case of tableTwo
            //Add the Values that are successfully sent to the database to successfullySentValues
            break;
        default:
            throw new IllegalArgumentException("UnsupportedTable: " + tableName);
    }
    return successfullySentValues;
}

0 个答案:

没有答案
相关问题