Android realm database for local font - android

I have a student table and name with local font.
So when I search student from local. I retrieve data like below code from real database.
RealmResults<Students> studentList = realm.where(Students.class).contains("name",query).findAll();
but I got 0 (zero ) size in studentList. But when i search with english name, it fine.
I would like to know, does realm support local language or not? or do i need something in configuration?

Related

how to add realm database rows (objects) in design or development phase?

lets say I want to make an app only read data from employee realmObject like
employee: {EmpNo String, EmpName String, DeptNo int, Sal int, comm int }
now I want to add about 1000 employee to realm database to use it in my app.
Is there any way to do this in design / development phase ?
or I have to build another project to add these records?
note: I have the data as csv or json, the important point that I want to add these records by developer not by user, how to do this?
I found the answer after some searching for it.
realm studio offers a way for this.
We can create new realm database file from csv file.
realm Studio>file menu>create realm from> csv.
Or after opening realm file, we can import csv data into current realm database file (one condition is: file name must match realm object in database).
realm Studio>file menu>import data from> csv.

SQLite in Android adding quotes to start and end of datelike string

Interesting issue while using SQLite in Android. I am seeing an inconsistency in the string length and quoting of a string between what is stored in the database and the materialized value seen in Java.
We are using an ORM called SugarORM to query the DB, but I've traced the offending code to the internal android.database.sqlite.SQLiteCursor class used within SugarORM, specifically the cursor.getString(columnIndex) method.
I have a string in the database that is an ISO data string 2019-03-25T19:19:39.664Z and is stored in a VARCHAR column . I have confirmed using DB Browser for SQLite that the length of the string as its stored in the database is indeed 24 characters. SELECT LENGTH(MyStringColumn) FROM MyTable WHERE ...
When I get the value of this string via cursor.getString(columnIndex), it is returning the string "2019-03-25T19:19:39.664Z". Notice the leading and trailing quotes. Java reports to me that the string is 26 characters long.
Any value that I store in this column that is not an ISO data does not have this behavior. I tried tracing the SQLiteCursor source back, but ultimately it ends up being a Native method and that's where my skill set stops.
Can anyone explain what might be going on here? I am probably just going to write a wrapper around my queries to get rid of the quotes, but its all very perplexing. The date string is being fed to a JavaScript interpreter and causing it to fail when creating a JavaScript Date object.
If it helps, I have replicated the behavior on both my S7 physical device and a Pixel 6 emulator.
As a quick get around you could use :-
SELECT length(replace(mystringcolumn,'"','')) FROM mytable;
or before using the original SELECT use :-
UPDATE mytable SET mystringcolumn = replace(mystringcolumn,'"','');
If this doesn't fix the issue, then for some reason it is the code that retrieves the data that is at fault.
e.g. consider :-
DROP TABLE IF EXISTS mytable;
CREATE TABLE IF NOT EXISTS mytable (mystringcolumn VARCHAR);
INSERT INTO mytable VALUES('2019-03-25T19:19:39.664Z'),('"2019-03-25T19:19:39.664Z"');
SELECT length(mystringcolumn), length(replace(mystringcolumn,'"','')) FROM mytable;
which results in :-
i.e. The 2nd row, 2nd column retrieves the appropriate value by using the replace function to strip of the quotes, if they exist.
As to why the quotes exist could depend upon either the way that the data is inserted (perhaps you have inadvertenly coded the quotes but the db being looked at isn't the actual database as copied from the App) or the way in which the data is being retrieved that for some reason adds them.
I don't believe it likely that the Cursor getString method has a bug in which the quotes are added, otherwise such an issue would likely be a recurring issue.

Receive a specific data from fire-base real time database using android

I develop an android application for students attendance according to their seat numbers. If the student entered his seat number, it will be stored into real time database in fire-base.
Now, what I need to do is to retrieve the empty seat numbers to a list view according to students' information. for example: database has 50 seat numbers entered, but seat number (25) is not in the database then it will be retrieved to the list view.
In general how can I do that with fire-base real time database?
This is how database looks like for one student
You will need to mark seat empty in your db to later only fetch the empty seats. In current situation there is no way to put a query which can retrieve data only for absent students.
Your screenshot is limited so I suggest this structure.
{lectureId}/
seatNumber: {
isEmpty: boolean,
.... your other data
}
Then you will use orderByChild("isEmpty").equalTo(false);
And for querying a set of data from realtime database, have a look at the docs:
https://firebase.google.com/docs/database/web/lists-of-data
you can use a boolean if student is present (present = true).
put this variabble in te object
then you can run a loop on datasnashot for
i < noOfSeats
and show in te ListView with a condition
if (!present){
showInList();
}

Sync android sqlite db and sql server in one way

I am developing an android application which have sqlite db on my device and sql server db on the main machine, the android device contain very small part of main db, so i don't want to replicate whole db. and I have my own webserver that upload/download data between databases,
my question is how I know which part of main database is changed to only download changed entries?
One usefull technique is using rowversion data type. You can see it as the server change number. You can get the current change number by using the MIN_ACTIVE_ROWVERSION() function. Then query from changes occurred form last downloaded change number to current change number and finally store the current change number as the last downloaded change number in the local SQLite database.
Something like this:
DECLARE #CurrentServerChange binary(8)
SET #CurrentServerChange = MIN_ACTIVE_ROWVERSION()
SELECT * FROM Table1
WHERE
RecordVersion >= #LastDownloadedChangeNumber
AND RecordVersion < #CurrentServerChange
SELECT * FROM Table3
WHERE
RecordVersion >= #LastDownloadedChangeNumber
AND RecordVersion < #CurrentServerChange
SELECT #CurrentServerChange AS CurrentServerChange
I assume RecordVersion columns are of type rowversion

Android ORMLite, use pre-populated database and use it

I have a pre-populated database, I hadd .csv and make a database in sqllite manager and imported all values into this database.
Now I put this database into android's assets folder and want to use this via ORMLite in my android application.
Please, need your help and will be thankful to you.
Now I put this database into android's assets folder and want to use this via ORMLite in my android application.
Boy there is a lot of ground to cover here to use ORMLite with this.
The short answer is that you will need to create Java objects which correspond to your database tables. Each Java object should have fields that match the table columns with the appropriate types with #DatabaseField annotations.
For example, if you CSV file was:
# name, id, street
Bill Jones,123,131 Main St.
and your table created is something like:
create table user (name VARCHAR(255), integer id, street VARCHAR(255));
The Java object you will need is something like:
public class User {
#DatabaseField(id = true)
int id;
#DatabaseField
String name;
#DatabaseField
String street;
}
Then you would use ORMLite to read in objects from your database. You should see the ORMLite home page and the Getting Started section of the documentation. For linking up with the existing database, you should read the section of the manual about using with Android.
Any additional questions I'd ask to the ORMLite Users Mailing List.

Categories

Resources