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