I'm making a school note app and I want to do an option to add, edit and delete school subjects. Everything works on IOS, but on Android works only adding.
Here's my code:
const editSubject = (oldSubjectName, newSubjectName) => {
db.transaction(tx => {
tx.executeSql(
'UPDATE subjects SET subject_name = ? WHERE subject_name = ?',
[newSubjectName, oldSubjectName],
(txObj, resultSet) => {
console.log('Przedmiot został zaktualizowany');
navigation.goBack(); // Wróć do poprzedniego ekranu
},
(txObj, error) => {
console.log('Nie udało się zaktualizować przedmiotu:', error);
}
);
});
loadSubjects(setSubjects);
};
const deleteSubject = (oldSubjectName) => {
db.transaction(tx => {
tx.executeSql(
'UPDATE subjects SET is_deleted = 1 WHERE subject_name = ?',
[oldSubjectName],
(txObj, resultSet) => {
console.log('Przedmiot został usuniety');
navigation.goBack(); // Wróć do poprzedniego ekranu
},
(txObj, error) => {
console.log('Nie udało się usunac przedmiotu:', error);
}
);
});
loadSubjects(setSubjects);
}
export const loadSubjects = (setSubjects) => {
db.transaction(tx => {
tx.executeSql(
'SELECT * FROM subjects WHERE is_deleted = 0',
null,
(txObj, resultSet) => {
setSubjects(resultSet.rows._array),
// const subjects = resultSet.rows._array;
console.log('Przedmioty zostały odświeżone');
},
(txObj, error) => console.log(error)
);
});
};
I was watching tips on internet but I didn't found nothing.