Expo SQLite is working with iOS but not Android

1. SDK Version: 38.0.8
2. Platforms(Android/iOS/web/all):

  • Iphone SE iOS 13.5 Simulator

  • Android Version 9 device

  • Also confirmed on Android Emulator

Setting up DB:

export const init = () => {
    const promise = new Promise((resolve, reject) => {
        db.transaction(tx => {            
            tx.executeSql(
                `CREATE TABLE IF NOT EXISTS image_posts (
                    id INTEGER PRIMARY KEY NOT NULL, 
                    title TEXT NOT NULL, 
                    image TEXT, 
                    sud TEXT, 
                    themes TEXT
                );`,
                [],
                (data) => {
                    console.log("Get here?")
                    resolve();
                },
                (_, err) => {
                    console.log("TABLE create error for image_exposures", err)
                    reject(err);
                }
            );
        });
    });


    return promise;
}

And the Insert for that table:

export const insertImagePost = (title, image, rating, themes) => {



    const promise = new Promise((resolve, reject) => {
        db.transaction((tx) => {
            tx.executeSql(
                `INSERT INTO image_posts (title, image, rating, themes) VALUES (?, ?, ?, ?)`,
                [title, image, rating, themes],
                (_, result) => {
                    console.log("Image RESULT => ", result)
                    resolve(result);
                },
                (_, err) => {
                    console.log("Or do you get here => ", err)
                    reject(err);
                }
            );
        });
    });


    return promise;
}

When I use either my Android device or my Android SDK emulator, those console.logs above the resolve() never fire. I never see the results there. I even assumed I didn’t know how promises work and tried to dive in to promise object instead of just returning it above.

However, the same code produces the desired result in iOS simulator. Nothing in Android. Is this a know issue, or is something wrong with my code. I am pretty sure I followed the docs and tutorials.

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.