无法使用 react-native-sqlite-storage 在 SQLite 中执行任何查询...我正在为 android 电视应用程序尝试

Unable to execute any query in SQLite with react-native-sqlite-storage ...i am trying it for android tv app

Blockquote

我还使用 table 创建了数据库并将其存储到 android/app/src/main/assets/sqlite.db 并将 createFromLocation 设置为 1 或 2

    useEffect(() => {
        try {
            db = SQLite.openDatabase({
                name: "sqlite.db",
                createFromLocation:"~sqlite.db"

            },
                sucessToOpen,
                errorToOpen
            )
        }
        catch (err) {
        console.log(err)
        }
    }, [])
    
    ....
    const sucessToOpen = async (data) => {
    
        console.log("DB connected",data)
            db.transaction(tx => {
                tx.executeSql(
                    'SELECT * FROM hydro',[],
                    (tx, results) => {

                        let datalength = results.row.length
                        alert(datalength)
                        console.log("results",datalength)
                    }, 
                )                   
            });
             
    }

这对我有用

db.transaction(tx => {
  tx.executeSql('SELECT * FROM TABLE_NAME', [], (tx, results) => {
    var temp = [];
    for (let i = 0; i < results.rows.length; ++i) {
      temp.push(results.rows.item(i));
    }
    console.log('TABLE_NAME', temp)

  });
});