块引用
我还使用表创建了数据库并将其存储到 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)
},
)
});
}