I'm trying to retrieve a long string saved in my Room database table. But I'm observing that the DAO query only returns the first 5,000 characters of that string.
I can see the full 11,000 characters exists in the database after I dump it to my device and inspect it (using DB Browser for SQLite). The full untruncated text exists in both my ENTRIES table and my ENTRIES_content table.
Room entity:
//@Fts4(tokenizer = FtsOptions.TOKENIZER_UNICODE61)
@Fts4
@Entity(tableName = "ENTRIES")
public class Entry {
private int rowid;
@ColumnInfo(name = "date")
private String date;
@ColumnInfo(name = "entry")
private String entryText;
public String getEntryText() {
return entryText;
}
}
DAO:
@Dao
public interface EntriesDAO {
...
@Query("SELECT *, rowid FROM ENTRIES WHERE date LIKE :date")
Entry getEntryByDate(String date);
}
Entry is retrieved from the database using the ViewModel pattern, which calls the repository layer, which then finally calls the DAO method that I've shown above.
mEntriesViewModel = new ViewModelProvider(this, factory).get(EntriesViewModel.class);
...
Entry currentEntry = mEntriesViewModel.getEntryByDate(entryDate);
String entryText = currentEntry.getEntryText();
entryText.length(); // 5000
I've tried using the two alternative queries below but they both returned the same truncated text:
@Query("SELECT *, rowid FROM ENTRIES WHERE rowid = (SELECT rowid FROM ENTRIES WHERE date LIKE :date)")
@RawQuery
Entry getEntryByDateRaw(SupportSQLiteQuery query);
// Used with this
//SupportSQLiteQuery query = new SimpleSQLiteQuery("SELECT * FROM ENTRIES WHERE date LIKE ?", new Object[]{ "%2024-01-01%" });
//return mEntriesViewModel.getEntryByDateRaw(query);
@Fts4annotation?