For a personal project, I am creating a quiz app written in Kotlin. To store information about a given question (four choices, the question itself, a category, and the correct answer), I have created a database using SQLite that stores said information. However, I am not unsure of a couple of things. One is where do I put my prepopulated
Tag: android
Android studio SQL – How to return data in a string array
I have an SQL method here. I would like to return the data in a String[] array. How do I do that exactly? Thank you! Answer You must define the array’s length and this can be done only after the Cursor fetches all the rows. Then set its length to the nimber of rows of the Cursor. Then inside the
SQL – How to return a list of data
I have this SQL method below, it is suppose to return multiple rows of data, but it is only returning one item every time I try to display the data. How do I fix that? Answer Inside the while loop in each iteration you change the value of LikeSong, so when the loop ends, LikeSong has the last value assigned
Problems with insertions after adding new tables to database
UPDATE: override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { if (oldVersion < 3) { db?.execSQL(ARTIGO_TABLE_NAME); } if (oldVersion < 3) { ...
Problems with SQLiteException: no such table
I have a database with two tables and every time I try to add a new item to the second table it says that there is no such table. Please help. DatabaseHelper: The add method from DatabaseHelper: The place where the new item creation is: Answer you may have changed the schema and did not increase the db version so
Update SQLite column with text of maximum length from same row
I have an (Android) SQLite table with two columns, Col1 and Col2, containing text. I want to update Col1 to contain the text with the maximum length out of Col1 and Col2 from the same row. I already have a working query but that query takes pretty long to execute on a large data set. Example data: Expected update result:
SQLite query for retrieve data Order By
(TableMain) Task_Id Task DateTime Repetition Snooze_Time 8 Call esha 2020-3-15 12:29 1 5 9 Meeting 2020-3-15 11:50 1 1 (TableRoutine) …
Android Studio Null object Reference
Creating an question/answer test application that scores you based on how many attempts it took to get it right (i.e on the first attempt 5 points, 2nd attempt 4 points… and so on) the questions are stored in a .DB file in asset folder and after testing the scoring logic I’m now trying to draw from the database. this is
Why do I fail to save data in my application?
I am a student and started working on android studio recently. I don’t know about it much. I am working on an application where I save the item name and its amount in the database and display toast …
How to implement BETWEEN Sql query in Firebase?
I am working on a android Firebase project. I need help in implementing this sql query in Firebase real-time database. Answer There’s good documentation on how to do firebase queries as well as apply them to ranges. Something like: Then you add the appropriate listener for what you are trying to do. (e.g. a ValueEventListener or a ChildEventListener via addValueEventListener