[go: nahoru, domu]

Skip to content

Commit

Permalink
limit text to 524288 characters which is always < 2Mb with UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jun 18, 2015
1 parent bf3cd76 commit 3f98bb1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public static boolean dropAllTables(SQLiteDatabase db) throws SQLiteException {
* https://github.com/android/platform_frameworks_base/blob/b77bc869241644a662f7e615b0b00ecb5aee373d/core/res/res/values/config.xml#L1268
* https://github.com/android/platform_frameworks_base/blob/3bdbf644d61f46b531838558fabbd5b990fc4913/core/java/android/database/CursorWindow.java#L103
*/
private static final int MAX_TEXT_LEN = 1024 * 1024;
// Max 512K characters (a UTF-8 char is 4 bytes max, so a 512K characters string is always < 2Mb)
private static final int MAX_TEXT_LEN = 1024 * 1024 / 2;
public static String maxSQLiteText(final String text) {
if (text.length() <= MAX_TEXT_LEN) {
return text;
Expand Down

0 comments on commit 3f98bb1

Please sign in to comment.