I'm making my first Expo app. I'm using SQLite for make DB and store data. I have a screen where I add school subjects to database. 2 weeks ago it works, but now it works only on IOS, on Android it didn't work.
Here's my add subject function:
const addSubject = () => {
console.log(currentSubject)
if(currentSubject && typeof currentSubject === "string" && currentSubject.trim() !== "") {
console.log(1)
db.transaction(tx => {
console.log(2)
tx.executeSql(
'INSERT INTO subjects (subject_name) VALUES (?)',
[currentSubject],
(txObj, resultSet) => {
let existingSubjects = [...subjects];
existingSubjects.push({subject_id: resultSet.insertId, subject_name: currentSubject});
setSubjects(existingSubjects);
console.log('Subject added');
setCurrentSubject(undefined);
},
(txObj, error) => console.log('Fail adding subject -> ' + error)
)
});
}
else {
console.log('You cannot add empty subject')
}
}
As you can see, I have added console logs to see where function stops and in the console I see 1 and 2. Also when i try to add an empty subject I see the log too after "else". But i didn't see the resultSet and error console logs because function didn't enter to "executeSql" part on Android.
Here I paste the logcat logs when i click the add subject button:
03-18 19:51:30.723 1271 1271 D TaplEvents: TIS / TouchInteractionService.onInputEvent: MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=465.9746, y[0]=754.92773, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=8700081, downTime=8699994, deviceId=4, source=0x5002, displayId=0, eventId=877171131 }
03-18 19:51:30.730 443 10854 D audioserver: FGS Logger Transaction failed
03-18 19:51:30.730 443 10854 D audioserver: -129
03-18 19:51:30.891 443 526 D audioserver: FGS Logger Transaction failed
03-18 19:51:30.891 443 526 D audioserver: -129
Can someone please help? I tried many things.
I have done new project but there's the same problem. On other devices or computer too didn't works.