Questions tagged [android-database]

0

votes
0

answer
7

Views

How do you pass a spinner selection from main activity to databasehelper to run a query and then pass the results to a second activity?

I am trying to make a small app that one the user selects on the spinner, the selection will be sent to the database helper to run the select query and then the select query results will be display in list view on a second activity. If run the query without trying to get the where function to work o...
Ryan Sohan
1

votes
1

answer
1.8k

Views

How to upgrade database with Sugar Orm?

I have a simple entity: public class MyEntity extends SugarRecord { String name; int value; public MyEntity() { //empty ctr for sugar orm } public MyEntity(String name, int value) { this.name = name; this.value = value; } } On App start I make an instance and save it like this: Log.i('db_test', '...
Adam Varhegyi
1

votes
1

answer
364

Views

NOT IN clause in Sugar ORM

I have a table users. From table users I have to select all users excepts some private users. I am storing private users Id in arraylist and then store into shared preference. Is there any way to use NOT IN clause in query to fetch all users except some private users.
Faisal Shaikh
1

votes
2

answer
28

Views

Android - application crashes when trying to add item to database

I am totally new to developing Android applications and I do not understand why my app crashes. Here's the code: public class ProductListActivity extends ListActivity { private ProductDataSource datasource; private ListView lv; private ArrayAdapter adapter; @Override protected void onCreate(Bundle s...
TheOpti
1

votes
1

answer
3.4k

Views

A SQLiteConnection object for database was leaked

I am beginner to android program getting below error, tried solution provided like clearing Google play store data on Emulator still getting same error, not using any database connection code but getting database was leaked, any help would be appreciated. Error 03-25 17:16:41.664 2335-2344/com.googl...
1

votes
1

answer
38

Views

unable to search database from button.setOnClick .getText as String becomes null

I am making android app that takes user input from EditText on press of button from button.setOnClick() and use the string.getText() to search the database. But the string becomes null and no way i can send it DbBackend.class where the search function is. I checked and database works fine on stati...
Sykox
1

votes
2

answer
29

Views

Inserted row id is greater than all the entry in table

I have a method like this: private void insertData() { ContentValues cv = new ContentValues(); cv.put(name, 'aName'); cv.put(lastName , 'aLastName'); Uri returnedUri = getContentResolver().insert(CONTENT_URI, cv); Log.e('number of row : ' , returnedUri.toString()); } I have 4 rows in my database and...
amir_70
1

votes
1

answer
768

Views

Android Studio Error in SQLiteDatabase - Drop if table exists

The following code @Override public void onUpgrade(SQLiteDatabase db, int i, int i1) { db.execSQL('DROP IF TABLE EXISTS ' + TABLE_NAME); onCreate(db); } always gives an error index table trigger or view got if Why is that? I hope anyone can help me. thanks in advance
Yannick
-2

votes
2

answer
434

Views

How do i fix this SQLite java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow

FATAL EXCEPTION: main Process: example.myproject, PID: 2608 java.lang.RuntimeException: Unable to start activity ComponentInfo{edgedev.andelaproject/example.myproject.Activites_and_Fragments.MainActivity}: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the...
Micklo_Nerd
1

votes
2

answer
33

Views

Room database - edit entities

I have a question. I edited my Room entity from this: @Entity(tableName = 'users') public class User { public User(String username, String email, String password){ this.username = username; this.email = email; this.password = password; } public User() {} @PrimaryKey @ColumnInfo(name = 'Username') pr...
michasaucer
1

votes
4

answer
121

Views

In which case user can clear shared preferences but not DB

As I know, when a user does 'clear data' or 'disable' any application, it's shared preferences are cleared and database is also cleared. So my question is, Is there any case, that user can perform, in which shared preferences gets cleared but database remains intact ?
Navratan Soni
1

votes
2

answer
918

Views

Reading a database from the assets folder [duplicate]

This question already has an answer here: Ship an application with a database 16 answers I have a db file in asset folder how can I use it. I must be able to read and write the database file If I use SqliteDatabase.open(context.openassest().open(filrname),null); Exception db file not found Don't...
Pradeesh
1

votes
1

answer
1.2k

Views

return sum and average using room

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 UserFitnessDailyRecord...
Sutirth
1

votes
1

answer
3.5k

Views

Deleting from a ContentProvider?

I want to delete the first item in my content provider. I'm trying to do this by deleting the row with id 0 (as shown below). This does not work--the app will not run with this code. public void onClickDeleteExercise(View view){ int ret_val = getContentResolver().delete(MyProvider.CONTENT_URI, MyPr...
user3293643
2

votes
6

answer
3.9k

Views

Updating SQLite database when releasing new version of the android app on the store

I'm using sqlite in my android app, my database file is called data.db. Let's suppose that I have two table in it one is having static values(read only) and second is saves dynamic values and pushed the app to the playStore. In the next version I updated the data.db and I updated the values in firs...
Pankaj
5

votes
1

answer
1.9k

Views

Android: CSV database vs SQLite database

How does a CSV database compare to an SQLite database in Android? Looking at other questions on StackOverflow, and reading Android Developer Documentation, I have seen SQLite databases being used far more often than reading data from a CSV file. There are also some questions where users have wanted...
Farbod Salamat-Zadeh
20

votes
1

answer
30.4k

Views

Firebase Permission denied Error

I am Very beginner to firebase and trying to get value from my database. but it showing me same error every time. W/SyncTree: Listen at /child failed: FirebaseError: Permission denied My firebase rules { 'Condition' : 'sunny', 'child' : 5 } my Androidmanifest.xml My mainactivity.java package com.mo...
Mohit Sharma
3

votes
3

answer
552

Views

Android database helper singleton - instantiate in activity or all fragments?

I have a DBHelper class set up as a singleton: public class DBHelper extends SQLiteOpenHelper { private static DBHelper sInstance; public static synchronized DBHelper getInstance(Context context) { if (sInstance == null) { sInstance = new DBHelper(context.getApplicationContext()); } return sInstance...
Simon
11

votes
2

answer
8.2k

Views

SQLiteConnection databases leak when running emulator

I was running the emulator and received the following errors about memory leak. It was interesting that the leaking database seems to be of the Google gms instead of a user database. Does anyone know how to fix it? Thanks! 09-27 15:55:07.252 2058-2068/com.google.android.gms W/SQLiteConnectionPool: A...
Benjamin Ting
2

votes
2

answer
12.3k

Views

How to convert video/audio file to byte array and vice versa in android.?

Am trying to convert audio/video to byte array and vice versa, using below code am able converting audio/video files to byte array(see below code) but am fail to convert large file(more then 50MB files) is there any limit.? how to convert byte array to audio/video file.? kindly help me out. public...
chethankumar_Gowda
21

votes
10

answer
13k

Views

Room cannot verify the data integrity

I am getting this error while running program with Room Database Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. It seems we need to update Database version, but from where we...
2

votes
1

answer
2.1k

Views

Why ORMLite & Green DAO are faster then traditional SQLite?

I would like to know why ORMLite & GreenDAO are faster then traditional SQLite ? As per my knowledge internally all are doing same quires for interacting with database like SQLite then why others are faster? Thanks in advance !!
Adarsh Yadav
6

votes
0

answer
672

Views

Failed to change locale for db '/data/data/com.scoreup/databases/scoreUp' to 'en_GB'

I have recently updated one of my application and I get the above error in very rare cases. This error occurs only when the user tries to update the app over the existing one. This doesn't happen every time and on every device. I have found a similar issue on Android SQLiteException: Failed to chan...
Anu
12

votes
2

answer
5.7k

Views

When to save data to database, onPause() or onStop()?

I know this question has been asked a million times, I myself though that I already knew the answer and that the correct one was that the only guaranteed call is to onPause(), so you should save your data there. However, in many places of android documentation they always suggest not doing heavy wor...
klifa
6

votes
1

answer
1.2k

Views

Sugar ORM listAll() not showing any data

I'm trying to get data from databse in a listview as shown below. long count = UserTableSugar.count(UserTableSugar.class); if(count>0) { UserTableSugar.listAll(UserTableSugar.class); List userTable = UserTableSugar.listAll(UserTableSugar.class); CustomAdapterListview madapter = new CustomAdapterList...
Aakash Joshi
1

votes
3

answer
449

Views

Best Practice - Saving Activity data to android database

I currently store my app data for an Activity in a Parcelable object. On orientation change, I save it and load it by using onSaveInstanceState and onRestoreInstanceState. I want to save the data to the database when the user exits the activity. And, I want to minimize the database calls. So, Whe...
BlackCursor
2

votes
3

answer
348

Views

How to insert existing DataBase in Android Project

I would like to insert an existing SQLite database into my Android project. In other words, I do not want to create it, but just to be able to access it within my app. How would I be able to access the database, and in which folder should I put it?
Thomas
4

votes
2

answer
10.7k

Views

IllegalArgumentException: Unknown URL content:// CONTENT

IllegalArgumentException: Unknown URL content:// ^ Having a nightmare with the above. I've checked my variables and paths but can't see what the issue is? Greatly appreciate any pointers! Here's my trace. java.lang.IllegalArgumentException: Unknown URL content://com.purewowstudio.topmovies.data...
Phill Wiggins
3

votes
1

answer
8.1k

Views

How to store the audio/Video file to SQLite database in android.? [duplicate]

This question already has an answer here: Storing Images in DB - Yea or Nay? 56 answers Am new to developing, am successfully store the images to database by converting the images in to bytes array and store it to SQLite database in BLOB (find below code). But am not getting how to store audio's/vi...
chethankumar_Gowda
6

votes
6

answer
11.2k

Views

Android: Delete entire database

I would like to delete a complete database created by my application. Do you know any adb command, or android sentence to do it?
Sosi
32

votes
5

answer
13.7k

Views

Database won't remove when uninstall the Android Application

I have two major questions. Database won't delete when uninstall app. Downloaded files won't delete while unstable the app. There is a database in my android application. I create it by java class as follows. public DataBaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERS...
KZoNE
1

votes
2

answer
51

Views

Android SQLite ForeignKey Column not found in Database

After the program runs Successfully and i extract .db file from Android Device monitor,I can find all my Tables and columns for each tables except the Column for Foreign key.Can anyone why this is happening? Is there something wrong with my Query? Here is my Code: private static final int DATABASE_V...
Niroj
4

votes
4

answer
8.5k

Views

Accessing the database of one application from another application

I've built an application and now I want to copy the database of that running application using my new backup application. I create my database path by doing DB_PATH + DB_NAME, using the following values: DB_PATH = '/data/data/iCam.Cam/'; DB_NAME = 'testdb.db'; I have code which copies the database...
Trikaldarshi
2

votes
0

answer
153

Views

Android - Structure of classes for DB Tables + POJO Class can be same?

I have 25+ tables and I have used Content Provider with Database. I have created separate files for each tables with following structure: TProductUnit.java in package of com.myapp.db.tables public class TProductUnit { /*** * Fields of TABLE_PRODUCT_UNIT Table ***/ public static final String TABLE_PR...
Pratik Butani
1

votes
1

answer
3k

Views

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

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 to...
2

votes
0

answer
283

Views

How can obfuscate Sqlite Database in android

I create External database with SQLite Expert Professional IDE and i insert many data into this database and i what add this database in my Android Project. but i want obfuscate this database. I want when other developers decompile my projects, not see my data in database! how can it?
1

votes
1

answer
2.1k

Views

One to many in DB Flow

I am trying to use DBFlow with my objects where i have relationship One TO Many (User have many Businesses), i was following tutorial at their offical wiki but it just dont want to work. Here are my user: @Column @PrimaryKey(autoincrement = true) private Integer id; @Expose @Column private Boolean a...
HyperX
1

votes
2

answer
33

Views

Spinner not adding all topics from DB

I have a database that is storing topics. I want to display all topics in a spinner. I can get the first topic in, but not the other three. All three log though: topicCursor: [email protected] str: test0 labels: [test0] dataAdapter: [email protected] sp...
JohnWilliams
1

votes
1

answer
4k

Views

Android - Realm How to get value [duplicate]

This question already has an answer here: Cannot retrieve field values from realm object, values are null in debugger 3 answers I'm trying to get a value I have saved in Realm, but I don't know how to do it.. the value is always null.. but when I'm debugging the code, the value appear as you can se...
gon250
3

votes
2

answer
2k

Views

How to use Sugar ORM's count() method?

I have an Email_Message class in my android app that stores email messages. It has an int field called 'messageType'. messageType == 1 means it's an inbox email, messageType == 2 means it's a sent email. I just started with Sugar ORM and I want to check in a class how many inbox email do I have sto...
Zoltán Umlauf

View additional questions