How to load two texts from db like in the picture? - java

How to load two texts like in the picture? That is, I have two texts stored in the database, one in English, the other in Russian. I am using a php script to load from the database. I also use Retrofit. How to take a string from two texts in turn and load it into a textview
this is what i want to achieve
UPDATE: I have two lyrics, one in English, the other in Russian. I need to pull out one line from the English text, and immediately below it the line from the Russian
db

Related

Displaying only the part of the line of txt file

I have a txt file with 200.000 lines. I want to show in AutoCompleteTextView only city name and country. I have idea (Show only characters) How to do that?
Example of line: (4463523 Denver 35.531250 -81.029800 US).
In this example i want to show Denver and US.
Well, unfortunately, there will not be a good way except reading the whole file in (use, for example, a Scanner). Then you can, for example, store the parts you want to access quickly in a HashMap. Depends on your specific usecase and how much memory/cpu time you want to spend.

How to store simple static predefined data in Android

Here is the thing; I have to store simple data which I have to define once (manually). I must have a functionality to search in it after using keywords. It's like this:
My first item
title:my_title
description:my_description (long, few hundreds words)
keyword1:my_keyword1
keywordx:my_keywordx
And I want a lot of items like this. For example 100 or 1000.
And after in code I want to make search function to look for specific items (as result may be a few, not only one) based on keywords and show the result as text in TextView field for example.
Do You have any idea how I should storage this data? I would prefer .xml file (person who will create data is not a programmer, it'll be much easier for him).
Put your data in JSON format as a text file, create a "res" folder, and put that text file in there. From the "your activity", read this file from the raw folder and parse the JSON.

Android: Display special characters in ListView

At this moment I am creating a small Android app, as a hobby.
It is not something serious: it makes a query from an sqlite database, and displays the results in a listview element. If you click on an item in the list, it makes another query with the content of the element, and displays the new results. (e.g. You tap on a city, it displays the restaurants in the city. If you tap on the city, it displays the foods available)
Now my problem is that most of these texts contain some special characters (like Ľ - u013D) that are not displayed correctly. And since they are not displayed correctly, I am unable to make further queries with them also.
I have tried many ways, mainly what I saw on this forum, however I am too noob for that unfortunately. This is what I have:
//DataBaseHandler is just a custom class creating and executing SQL queries, nothing special. It extends to SQLiteOpenHelper
DataBaseHandler db=new DataBaseHandler(this);
//getStations returns a List<String> object with the required items, contains raw strings
ArrayList<String> StationList=(ArrayList<String>) db.getStations(i.getStringExtra("jaratszam"));
db.close();
lv=(ListView) findViewById(R.id.listStation);
ArrayAdapter<String> aa=new ArrayAdapter<String>(this, R.layout.tv, StationList);
lv.setAdapter(aa);
I have tried to modify the strings I got back with Html.fromHtml, also CharSequence[], but none helped (I guess i did not use them correctly). I have modified my database also, I have changed the special characters to html codes, like
&#00E1;
Could you please enlighten me what should I do exactly?
Thanks in advance.
You probably need to user the correct character set for your String, although UTF-8 (which is the default) should support most foreign and special characters. Here's how you create a new String with a custom charset from an old String:
String newString = new String(oldString.getBytes(), Charset.YOUR_CHARSET_HERE);
Now my problem is that most of these texts contain some special
characters (like Ľ - u013D) that are not displayed correctly.
Try Encoding your string before putting it in database and decode it before using it in your application.

how to make table formatted text file in android sd card?

I see this to make text file and it also helps me out but in all examples i see that they just making string in notepad or we can say text file...
Can any one say that how to make table formatted text file in android??
i want to make file(invoice)
This is most likely going to involve some some slightly messy string processing. Assuming you have your data in an acceptable format (such as string arrays), you should be able to construct a single java string representing the whole table, and then use the code you found already to print it to a file. Use the escape character \t to separate between columns and \n to separate between rows.
That would be TSV format, and it is very easy to generate. Just add a TAB after every field, and a CR/LF pair after every record.

Best way to store text data in an android app?

I've made an Android application which contains most used German words and sentences. The application contains a CSV file which stores all the data.
Currently it is working as expected but I want to ask if there is a better way to store such data directly in the app?
I'm also thinking about the ability to update the data via internet like adding new words and sentences.
Thanks!
Miretz
If you want to modify the content (update, remove etc.) I would suggest using SQLite DB which has a pretty nice built-in integration with the Android platform.
There are 2 types SQLDatabaseLite and SharedPreference. Major difference between both is that one is organized and the other not so.
If you need a quick use of a storage facility within your app for example changing text sizes between activity SharedPrefference works best for you.
If you have a complex database system where you need more than one data to be saved for a particular event SQLDatabaseLite is for you example of this is spreadsheet of data for customers; Name, Phone Number, etc.

Categories

Resources