Questions tagged [android-database]

0

votes
0

answer
3

Views

Is there a shorter workaround to reduce the number of AsyncTask in my Room DataBase Repository

I am trying to simplify the number of lines for my codes in the repository. Currently there is a lot of repetition in my codes. Many of the solutions online only involves inserting once into the table. I need to do insert() on many tables. I want to reduce the repetition for writing the same inner A...
Peter
1

votes
0

answer
90

Views

Use Selection and Selection Args instead of URI matcher

I am confused the whole point of using URI matcher is to identify whether we want to work on particular row or the whole table. so in case we want to work on particular row with id 'ID' we attach id to the path of URI and then URI matcher will identify what kind of URI pattern. but on the other hand...
Asim Khan
1

votes
0

answer
32

Views

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 according to these colors.So that I have 3 activities th...
1

votes
1

answer
43

Views

Encoding a video (mp4) in Android

I want to store a video file in sqlite database and retrieve it from the database. I can store it in database with code that I have. FileInputStream fileInputStream = new FileInputStream('/sdcard/download/video.mp4'); byte[] image = new byte [fileInputStream.available()]; fileInputStream.read(image)...
amir iranmanesh
1

votes
0

answer
48

Views

COLLATE function in Realm Android

I am working on realm Database in one of my projects. I want to implement COLLATE function(SQL) in one of my realm queries. Is there any way I can add that. My Realm Query: ArrayList = (ArrayList) realm.copyFromRealm(realm.where(FolderTable.class).equalTo('folderType', 'ICD10').and().equalTo('isFold...
Mehta
1

votes
0

answer
36

Views

Search in EditText to Listview with Database

This is my first time here. I have searched a lot and do not understand the following: I have connected my database to be projected in the listview, but now I want to search or filter the listview based on the item that you input in the EditText. I have saved the database manually on the phone in t...
Anne Leona
1

votes
0

answer
123

Views

How to update fragments in viewpager in tablayout with database using only one fragment?

this is Sqlite helper class to retrive data from database public class Simple1 extends SQLiteAssetHelper { private static final String DATABASE_NAME = 'yogalite.db'; private static final int DATABASE_VERSION = 1; private static final String ID='id'; private static final String NAME='name'; private s...
user9751873
1

votes
0

answer
29

Views

How to set list data to recyclerView from activity via interface in room persistence database?

I am using Room persistence library to store data, want to set a list of data to recyclerView from database with button click. I have got data list from database using List employees = database.employeeDao().getEmployeeList(); and Have a method in Dao interface class called @Insert void insertList(...
Shah Alam
1

votes
0

answer
66

Views

Android database not inserting entries

I am trying to make simple database entry app where When I click on button to initiate The Enter function it should insert some values into the database. But it's not working. The main Activity button onclick function ( variable for database are SQLiteDatabase db; private AppDBHelper mhelper;...
Minhal ali khan
1

votes
2

answer
97

Views

Data is not updated normally (room database)

I need when refresh page make request to API and insert getting data to my room database. But when I try to insert data I get io.reactivex.exceptions.OnErrorNotImplementedException: UNIQUE constraint failed: data.id (code 1555). So I decided to check is my table empty and if isn't make update reques...
anna
1

votes
1

answer
32

Views

Should I create a class that inherits SQLiteOpenHelper for each table in my database?

I need to create an android app database , but I was wondering if I should create one class that inherits SQLiteOpenHelper for each table that exists in my database ? Or should I create One class : for example MyAppDatabase that inherits from SQLiteOpenHelper and create all my tables in onCreate met...
Yassine El Baaj
-1

votes
0

answer
20

Views

Why Database Gets Created Every Time I Restart My Application?

I have a database that gets created when application starts. It is intended to download a file and create the database from the file. The problem is that it downloads the file and create the database every time I reopen the app. The MainActivity checks for the existance of the database using this sn...
miatech
1

votes
1

answer
3k

Views

How to access main.db of Skype App to display Recent Tab logs in Sample Android Application?

I'm trying to make an Android Application in which i want to show the logs/Call History of Skype User(Recent Tab). As much as I know, Skype stores all the Contacts in a Server and after logging in for the first Time , it syncs All the Contacts using Sync Adapter in my local Storage i.e Contacts DB b...
Abhinav Dua
1

votes
1

answer
3.1k

Views

How can I pass database records to second activity and display in it with listview?

I'm new to android and java. Let me explain my project. I'm writing an Android application. I want to create a database and insert,delete, modify datas from textviews. And display these datas using ListView another activity. My first question is, how to send these datas another activity? Second, I...
BusraD
1

votes
3

answer
127

Views

How can I make an Adapter ListView on a Fragment using an SQL database?

I'm trying to call or see a ListView with this kind of specification: Wireframe Here is my code. This is the fragment named EducacionFragment, and here is where I want to call the layout 'eventos': public class EducacionFragment extends ListFragment{ @Override public View onCreateView(LayoutInflater...
Juan Salazar
1

votes
2

answer
116

Views

Inserting in SQLite database from file, only one row inserted

I'm inserting rows in android SQLite database from a file. In the onUpdate function in the databaseHelper I call the insertInDb function: InputStream is = null; AssetManager assetManager = context.getResources().getAssets(); String fileLine = ''; String[] data; ContentValues row = new ContentValues(...
Christoph
1

votes
2

answer
309

Views

Getting only last values from database in android [closed]

I have stored values in database and now I am trying to get values from database. all values are stored in data base but when I get values in String list it only return the last values .following is my code .any help will be appreciated. please public List GetBigRun() { List bigRun_list = new ArrayL...
Sohail Yasin
1

votes
1

answer
260

Views

How to use external database in android

I want use External database in my application. in my application has 4 fragment, and show any fragments one of tables in database (database has 4 tables). but when start run the application, show me this error : 03-06 16:59:46.350 9654-9654/com.tellfa.dastanak E/AndroidRuntime: FATAL EXCEPTION: ma...
Dr.Master
1

votes
2

answer
245

Views

How to reset count for every half an hour based on date and time android?

I am working in beacon type where I need to reset count for every half an hour. When the device gets triggered, I will insert data in db for corresponding date and time and counter. But when it reached half an hour, need to reset counter from 1. How to handle this? Here is code what I tried. This da...
Shadow
1

votes
1

answer
57

Views

How to display live progress of a message? What data structure/view to use?

I have a working service that allows users to send emails over Ethernet. This service is a part of a greater application that allows users to view the progression of those messages (both sending and receiving) as they are transmitted. My service is responsible via callback interfaces for notifying w...
gabe3vino
1

votes
3

answer
2.4k

Views

How to secure android database file?

I have a problem. I am using xyz.db file and which is stored in asset folder. I am copying all data from xyz.db to application db which is stored in data/data/com.xyz/abc.sqlite in storage folder. Now I want to secure asset's xyz.db file. Because It can be easily extract from apk by reverse engineer...
1

votes
1

answer
1.3k

Views

how to sync android contacts with firebase database

I am new to android programming and I am Developing an App in which the user has an account in firebase and he wants to sync his/her mobile phone contacts with the firebase database contacts. One way is to get all the firebase contacts and compare with the user phone contacts and filter out the simi...
Oswald
1

votes
2

answer
1.1k

Views

Realm and Android DataBinding

I'm trying to use Realm in my app, but without success. The problem seems to be the fact that i use databinding and Realm in the same application. The objectif, is let the user to use View to enter some data that i get with databinding, and insert into a Realm Database I have the following error :...
kevingiroux
1

votes
1

answer
45

Views

andorid-db query to get last records or first of the group if the last record is duplicate of previous

There is a table status that contains data as shown below: Id Status TimeStamp ------------------------- 1 StatusC 1234561 2 StatusC 1234562 3 StatusB 1234563 4 StatusA 1234564 5 StatusA 1234565 6 StatusA 1234566 What query will return the following r...
coder1087
1

votes
3

answer
78

Views

Android recyleview listing using with database not working

I am developing an app for listing details in database. The listing is not working. but it is showing in log as fine. Why my recyclerview listling is not working. when i am using bean1 = new Bean(cn.getName(), cn.getNumber(), cn.getSpeeddial()) it shows error. My codes are shown below. SpeedDialView...
fazil tm
1

votes
2

answer
108

Views

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 seems to be the main cause of this kind of problem....
1

votes
1

answer
14

Views

_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 table drop temp table Steps 1 - 4 execute as expected...
BiGGZ
1

votes
1

answer
70

Views

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 Adapter public class HistoryAdapter extends Array...
Ahmad Meer
1

votes
1

answer
51

Views

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 automatically rather than update. Note : I've actuall...
Sebastien FERRAND
1

votes
1

answer
864

Views

How do I update columns of a Room entity only if it's null?

Is there a way to update columns of an entity only if the columns are null? Here's my Update function in my DAO interface: @Query('UPDATE media SET media_name = :mediaName, media_data = :mediaData WHERE id = :id') fun update(id: Int, mediaName: String?, mediaData: String?) ... because as of now, a v...
DaveNOTDavid
1

votes
2

answer
79

Views

Best way to store dynamic data?

I am developing a launcher for Android and need some advice on designing my persistent storage system. I wish for people to be able to create different categories for their apps (e.g Media, Utilities, Social). Users must be able to choose the order of their apps and apps can appear in more than one...
FrazorLazer
1

votes
1

answer
78

Views

Gradle Multi module annotationProcessor compilation issue between Room Database And Glide Plugins

below is my build.gradle file dependencies dependencies { def room_version = '1.1.1' implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.google.co...
Feroz Siddiqui
1

votes
1

answer
0

Views

How to make reference to another tables? (SQLite)

I am making a list of Images with Tags so I decided to make a SQLite Database with ImagesPath and Tags. I know that I have to combine these two tables in the state many do many but i really don't know how. I have three tables: 1)ImagesPath (INT id, TEXT imagePath) 2)Tags(INT id, TEXT title) 3)ImageT...
MrFisherman
1

votes
2

answer
0

Views

Live data returning old values , onChanged is triggering multiple times

I am using live data to update some view of the activity. the view contain question numbers both total question number and answered question number eg: 2/10 (answered/total) the questions can be filtered using actors, if no actor is selected then it will list all questions (consider the total questi...
MarGin
1

votes
1

answer
0

Views

How to create an android app database that will be modified in real time?

i just started Android Development a few weeks ago for a college project : an Android application that manages the transport of students (with several buses) from their home to school with a geolocation service. So I have already made a schema of my database. I do not want this database to be local...
Yassine El Baaj
1

votes
2

answer
568

Views

Handling database changes when app version number changes

I'm trying to figure out the best way to handle database upgrades and versioning. At the moment I delete the database and log users out when I do a point release, which isn't a great experience. Can anyone recommend any tips for doing this?
1

votes
2

answer
478

Views

Closing cursors/database in Android

Here is the code: public List getXImages() { List images = new ArrayList(); SQLiteDatabase database = this.getWritableDatabase(); String sql = String.format('SELECT %s, %s, %s FROM %s', A, B, C, TABLE); Cursor result = database.rawQuery(sql, null); if (result.moveToFirst()) { do { String a = result....
b85411
1

votes
2

answer
284

Views

How to apply SELECT date('now') query in android?

I am working on a project and now I have been stuck on a weird stage. I know that we can execute any query that has to do anything with database we can write that using: Cursor cursor = db.rawQuery('SELECT * FROM table_name', null); But now I want to execute this query: 'SELECT strftime('%s','now','...
activesince93
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

View additional questions