Questions tagged [android-database]

General programmatic usage of databases on Android

Databases and tools related with persistence supported by the Android operating system.

584 questions
1
vote
0 answers

How can I eliminate my database"s values for putting to my arrays according to an order?

I have a database for my application.It has 5 different columns. Fifth column name is color.This column has 2 different type of colors.(blue and orange ) Other columns are only data and every data has a color.I want to eliminate my all data to…
1
vote
1 answer

Android SharedPreference and database on app update

Let's say I'm pushing a new version app to google play (17 to 18). Is there a chance some devices have SharedPreference wiped out ? How about the local database ? I think it could happen if some device somehow where to uninstall reinstall the app…
1
vote
1 answer

Room how to model Entity with nested collections

I try to refactor some code and move several architecture to use Room Database from architecture components. I have such object, which i use often, getting it from cache. Here what it looks like: public class LocationEvents { private…
K.Os
  • 5,123
  • 8
  • 40
  • 95
1
vote
0 answers

How to use Content Resolver to query SQLite database?

Currently i'm using db.query() method to access database directly and code is running perfectly. But when i try to use Content Resolver to access database using Cursor cursor = getContentResolver().query() method, the app doesn't start. I have…
1
vote
1 answer

DBFlow - unable to delete data

I'm using DBFlow to manage my database in Android. I'm trying to delete a record based on a query. When I execute the following code, I don't get an error but the record still persists. Anything I'm doing obviously wrong ? SQLite.select() …
ArdenDev
  • 4,051
  • 5
  • 29
  • 50
1
vote
2 answers

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…
amir_70
  • 737
  • 1
  • 10
  • 27
1
vote
1 answer

Delete Row By id from SQLdatabase in Android

I’m Trying to Delete a row of listview from the list adapter where if a button is clicked it will look for the id and send it to the database for deletion. The method I wrote return the last id available and not the selected one. Here is the list…
Ahmad Meer
  • 89
  • 1
  • 9
1
vote
1 answer

_id conflict when backing up tables in onUpgrade

I want to persist table data across database structure changes, so the basic flow is as follows: create temp table populate temp table with data from primary table drop primary table onCreate() is called populate primary table with data from temp…
BiGGZ
  • 503
  • 4
  • 17
1
vote
1 answer

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…
MMG
  • 390
  • 1
  • 6
  • 20
1
vote
1 answer

Create a global Realm file for a collaborative android app

My app is a collaborative app where users should be able to write/read into a global Realm file to share data between them. I would also like to include some initial data (realmObjects) in the Realm file which will be common to all users. User will…
1
vote
0 answers

android.database.sqlite.SQLiteCantOpenDatabaseException: with ContentProvider

Although This question has been asked many time but they all are discussing about Sqlite Database. But in my Application I am using Content Provider for database. and I am using this for chat window.Using aSmack Lib. Below is exception I am…
Kshitij Vyas
  • 83
  • 1
  • 9
1
vote
2 answers

App crashes at getWritableDatabase: NullPointerException

I'm trying to make an app that involves a database. I'm using a ContentProvider and it's crashing in the query method when it tries to getWritableDatabase. It returns a NullPointerException. I know for a fact that the Context isn't null, since that…
1
vote
2 answers

Cursor query returning 0

I am building an application with database but a problem arises when I am retrieving the values from the database it returns empty (i.e. returned cursor has 0 tuples) and I am sure that database contains some information into it. I am providing my…
Sam
  • 23
  • 3
1
vote
1 answer

Connect android application to a server database

I want to connect my android application with a SQL database which is stored in an another computer. I want to use that computer as a server. I think there is a method to connect with that server computer using it's IP address. I use android studio…
Methmal Godage
  • 736
  • 1
  • 6
  • 12
1
vote
3 answers

How do I delete by ID in SQLite?

I am quite new Android Development and figured I should start by trying to create a simple ToDo List App using SQLite. I have all of the basic functionality in place: adding, updating, and deleting tasks. However, I am adding, updating, and deleting…
sumowrestler
  • 345
  • 5
  • 19