i create a program that save data to database in react native but when reopen expo and run again program database were deleted and create new empty database
async save() {
if (!(await FileSystem.getInfoAsync(FileSystem.documentDirectory + 'SQLite')).exists) {
await FileSystem.makeDirectoryAsync(FileSystem.documentDirectory + 'SQLite');
}
await FileSystem.downloadAsync(
Asset.fromModule(require('../assets/factor.db')).uri,
FileSystem.documentDirectory + 'SQLite/factor.db'
);
const db = SQLite.openDatabase('factor.db');
db.transaction((tx) => {
tx.executeSql("INSERT INTO factors (created_at,customer,sender,pay,off,description,customer_id)
values(?,?,?,?,?,?,1)",
[this.state.date, this.state.customer, this.state.sender, this.state.payment, this.state.offset,
this.state.description],
(trans, rows) => {
alert('factor added');
console.log(rows);
db._db.close();
},
(err, msg) => {
console.log(msg);
});
tx.executeSql(
"SELECT * FROM factors",
[],
(trans, res) => {
console.log(res.rows);
db._db.close();
},
(err, msg) => {
console.log(msg);
});
}, null);
}
and after run select sql return one row and dont show prev rows added before