I spend almost 10 hour just to get data from the pre populated database. I place my db file for android in \android\app\src\main\assets
i am using react native version 0.73.4
here is my code
import SQLite from 'react-native-sqlite-storage';
const initializeDatabase = async () => {
try {
const db = await SQLite.openDatabase({
name: 'kitabosunnat.db',
createFromLocation: '~kitabosunnat.db',
});
await db.transaction(tx => {
tx.executeSql(
'SELECT * FROM Favrouit',
[],
(tx, results) => {
const temp = [];
const rows = results.rows;
for (let i = 0; i < rows.length; i++) {
console.log('Row:', rows.item(i));
temp.push(rows.item(i));
// Process and use the data as needed
}
setData(temp);
},
error => {
console.error('Error executing SQL query:', error);
},
);
});
} catch (error) {
console.error('Error initializing database:', error);
}
};
useEffect(() => {
initializeDatabase();
console.log(data);
}, []);
with all the solution i searched on google i still have the following problem
Error executing SQL query {"code": 0, "message": "no such table: categories (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM categories"}
Note: table is present in the database with correct spelling
i have tried all the solution but cannot succeed
I spend almost 10 hour just to get data from the pre populated database. I place my db file for android in \android\app\src\main\assets i am using react native version 0.73.4
here is my code import SQLite from 'react-native-sqlite-storage'; const initializeDatabase = async () => { try {
}; useEffect(() => { initializeDatabase(); console.log(data); }, []); with all the solution i searched on google i still have the following problem
Error executing SQL query {"code": 0, "message": "no such table: categories (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM categories"}
Note: table is present in the database with correct spelling i have tried all the solution but cannot succeed