admin管理员组文章数量:1123924
[tag:Hello Guys, I am developing mobile app using React-native and sqlite database. I tested it on Ldplayer emulator
let db: SQLite.SQLiteDatabase;
const dbPath = FileSystem.documentDirectory + 'quizzes.db';
async function initializeDatabase() {
const fileInfo = await FileSystem.getInfoAsync(dbPath);
try {
db = await SQLite.openDatabaseAsync('quizzes');
`this is the connection with my quizzes.db, but not connect now`
await db.execAsync(`
PRAGMA journal_mode = WAL;
CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY NOT NULL,
value TEXT NOT NULL, intValue INTEGER);
INSERT INTO test (value, intValue) VALUES ('at', 123);
INSERT INTO test (value, intValue) VALUES ('bt', 456);
INSERT INTO test (value, intValue) VALUES ('ct', 789);
`);
const firstRow = await db.getFirstAsync('SELECT * FROM test');
const allRows = await db.getAllAsync('SELECT * FROM test');
console.log("this is all rows", allRows)
} catch (error) {
console.error('❌ Error initializing database:', error);
}
}
useEffect(() => {
initializeDatabase()
})
enter image description here
but running this app, it does not connect my db "quizzes.db" so it created test.db
because it can not search my db.
I wanna check test.db 's location in ldplayer.
How can I find this location and edit it?
I will be happy to solve this problem.
Let's communicate this
(this is my skypeID: live:.cid.cf2076082a6fe1cb)
Regards.
I tried to use test.db, and get data from it. ]
本文标签: react nativeHow can I connect sqlite db in mobile emulatorStack Overflow
版权声明:本文标题:react native - How can I connect sqlite db in mobile emulator? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736607108a1945356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论