Note that there are some explanatory texts on larger screens.

plurals
  1. POEditing cursor data before display
    primarykey
    data
    text
    <p>I'm new in android and Java world and I want to edit cursor data result before displaying it. To do so I wrote the following code</p> <pre><code>private static final String[] INTERNAL_COLUMNS_1 = new String[] { MediaStore.Audio.Media._ID,MediaStore.Audio.Media.TITLE}; private static final String[] INTERNAL_COLUMNS_2 = new String[] { MediaStore.Audio.Media._ID, "fixString(" + MediaStore.Audio.Media.TITLE + ")"}; private Cursor getInternals() { return query( MediaStore.Audio.Media.INTERNAL_CONTENT_URI, INTERNAL_COLUMNS_1, constructBooleanTrueWhereClause(mFilterColumns), null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); } private Cursor mCursor = new SortCursor(getInternals()); public String fixString(String oldstr) { String str = new String(oldstr); str = str.replace("_", " "); if (Character.isLowerCase(str.charAt(0))) { str = str.substring(0,1).toUpperCase() + str.substring(1,str.length()); } for(int i=1;i&lt;str.length();i++) { if ((Character.isUpperCase(str.charAt(i))) &amp;&amp; (Character.isLetter(str.charAt(i))) &amp;&amp; (Character.isLowerCase(str.charAt(i - 1))) &amp;&amp; (Character.isLetter(str.charAt(i - 1)))) { str = str.substring(0,i) + " " + str.substring(i,str.length()); } } return str; } public static void main(){ for (int i = 0; i &lt; mCursor.getCount(); i++) { mCursor.moveToPosition(i); String string = mCursor.getString(1); Log.d("OUT"," string = "+ string); } </code></pre> <p>Using <strong>INTERNAL_COLUMNS_1</strong>, the log shows </p> <pre><code>TomSkinner Jack_Smith foxRayan </code></pre> <p>I want to have as the cursor result :</p> <pre><code>Tom Skinner Jack Smith Fox Rayan </code></pre> <p>So I used <strong>INTERNAL_COLUMNS_2</strong>, but I have exception </p> <pre><code>android.database.sqlite.SQLiteException: no such function: fixString </code></pre> <p>Does any one know how to do so, or any other idea ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload