android-database

return sum and average using room

筅森魡賤 提交于 2020-05-13 06:19:40
问题 My table is structure is as follows: @Entity(tableName = "userFitnessDailyRecords") public class UserFitnessDailyRecords { @NonNull @PrimaryKey private Date forDay; private int stepCount; } The query I am writing for getting sum and average is as follows: @Dao public interface UserFitnessDailyRecordsDao { @Query("SELECT SUM(stepCount), AVG(stepCount) FROM userFitnessDailyRecords where forDay BETWEEN :startDay AND :endDay ORDER BY forDay ASC") UserFitnessDailyRecords

SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1

时间秒杀一切 提交于 2020-04-13 03:42:06
问题 I am getting below exception only in android 9, after reinstalling everything looks good, Exception: android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1... Code: Cursor cursor = database.query(......); if(cursor == null || cursor.getCount() < 0) { //Here is the error Log.d("Error", "count : null"); return ""; } Edited: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done

send a row from a listview saved in database sqlite to another listview and make it do the same as the row in the first listview

家住魔仙堡 提交于 2020-01-24 19:30:42
问题 i have two activities each one of them have a listview the first one is connected to a data base and get its data from strings.xml i want to send a row to the other listview in the aother activity and make it do the same as if it was in the first list view i did that before but all the data was saved in the database directly (no strnigs.xml) here is my code please help me public class DB_Sqlite extends SQLiteOpenHelper { public static final String BDname = "data.db"; public static final int

How can I update a TypeConverted column of an entity in Room Dao function

ぃ、小莉子 提交于 2020-01-03 09:09:19
问题 I have an @Entity which holds a variable(list of custom object) along with other fields for the table. I am able to insert, fetch and delete from this entity. But I am facing an issue in updating the entity: I want to update that particular field which holds a list of custom object in the table but while compilation it throws an error: error: Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider

Room Using Date field

徘徊边缘 提交于 2020-01-01 02:49:10
问题 I am using date converter class to convert my date object. However, I still encounter an error saying. error: Cannot figure out how to save this field into a database. You can consider adding a type converter for it. My Date Converter class public class DateConverter { @TypeConverter public static Date toDate(Long dateLong){ return dateLong == null ? null: new Date(dateLong); } @TypeConverter public static long fromDate(Date date){ return date == null ? null :date.getTime(); } } My Database

Android Database help needed

大城市里の小女人 提交于 2019-12-26 09:32:08
问题 I have an activity which has two edit text fields: one for the title and the other for the story. The entries made two text fields are saved in the database, also the database has a ROW_ID , TITLE_ID and STORY_ID . The entries are displayed in a list view . When an item is long clicked, I get the row id corresponding to that item. How should I get the TITLE_ID and STORY_ID from this? 回答1: Say, you have the corresponing row id of item which is long clicked in a variable rid . Then run the

Unable to get provider (ClassNotFoundException) Xamarin

混江龙づ霸主 提交于 2019-12-25 08:58:41
问题 I am working on a Solution in Xamarin which contains at least 4 different Android Applications. My Goal is to create a shared content provider for all of these four apps so that I can have the Master data in one place (If an application updates that data, I can get that updated version in another app). In Visual Studio, I have create a PCL project where I have defined the Content provider (which I can reference in all applications and do the CRUD operations). My Content Provider is as follows

How to store video content in SQLite database (not the video path)

我是研究僧i 提交于 2019-12-25 02:18:56
问题 I want to store a video in sqlite database. P.S. I do not want to store the path but the actual video contents. I have converted the video in byte array and stored byte array in sqlite database. Upon retrieval bytearray is being converted into File. But video is not playing. Please help. 回答1: I want to store a video in sqlite database. P.S. I do not want to store the path but the actual video contents. Unless the videos are very short and take up little space (say up to 200k each, perhaps 1

SQLiteConstraintException: column id is not unique (code 19) exception when updating row

时光总嘲笑我的痴心妄想 提交于 2019-12-24 13:41:41
问题 I have a table in my database, when adding new record I am checking if the record exists using the id.If it does, I want to update the record and if it doesn't add a new record. But am getting the exception: 2006-2259/? E/SQLiteDatabase﹕ Error inserting id=080333 phone=080333 total_owed=15050.0 total_debts=0 name=Alison Jones android.database.sqlite.SQLiteConstraintException: column id is not unique (code 19) This is the method that checks if a record exists: public boolean checkIfExists