The code itself:

private void openFile() { db = sqlHelper.getReadableDatabase();// открываем подключение к базе данных userCursor = db.rawQuery("select * from " + DatabaseHelper.TABLE, null); String[] headers = new String[]{COLUMN_NAME, COLUMN_YEAR}; userAdapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item, userCursor, headers, new int[]{android.R.id.text1, android.R.id.text2}, 0); listView.setAdapter(userAdapter); } 

If you write so many characters:

  db.execSQL("INSERT INTO "+ TABLE +" (" + COLUMN_NAME + ", " + COLUMN_YEAR + ") VALUES ('Том Смит', 19asgdahsgdagsdiagsidagsiydgaigsdiagisdia);"); 

Then the output is this value: enter image description here

  • And what type of data does the column have? String ? - Flippy
  • @Romag what is the question? - Anatol
  • How to make so that only the first 10 characters from the record would be displayed for example. - Romag
  • one
    You want to know how to display the number in the last item not in an exponential form, but in a simple one? - pavlofff
  • Yes. How to reduce values ​​to a simple reflection of 10 characters for example. - Romag

1 answer 1

  1. check the validity of the input data, the year should be correct.
  2. or longer solution. write your class which extends SimpleCursorAdapter. And in the TextView where the year is set, use formatting, for example

    .setText (String.format ("%" + maxlength + "d", year));