5

I have 11Mb JSON file and these file will be write on Dao but when I save all data. I got this error;

/data/user/0/com.test.save/databases/ChannelDb-wal 6946352 bytes: Bigger than 1048576; truncating

My codes;

AppDatabase dbRoom = Room.databaseBuilder(getApplicationContext(),
        AppDatabase.class, Constants.CHANNEL_DB).build();

AndroidNetworking.get(user.getRemote())
        .setTag(Constants.GET_CHANNEL_LIST)
        .setPriority(Priority.HIGH)
        .build()
        .getAsOkHttpResponseAndParsed(new TypeToken<List<Channel>>() {
        }, new OkHttpResponseAndParsedRequestListener<List<Channel>>() {
            @Override
            public void onResponse(Response okHttpResponse, List<Channel> channels) {
                AsyncTask.execute(() -> dbRoom.channelDao().insertAll(channels));
            }

            @Override
            public void onError(ANError anError) {
                Log.d(TAG, "Check 4");
                hideProgress();
                Toast.makeText(getApplicationContext(), getResources()
                        .getString(R.string.an_error), Toast.LENGTH_LONG).show();
                Crashlytics.log(Log.DEBUG, TAG, anError.getErrorDetail());
            }
        });
secret
  • 742
  • 1
  • 7
  • 24

1 Answers1

3

this WAL has a limit of 1MB set, while the cursor-window on Android has a hard limit of 2MB.

therefore it is rather pointless, what you are trying to accomplish, even if disabling the WAL.

because even if you'd manage to somehow insert, you're not able to retrieve that again.

basically, you have two plausible options available:

a) parse the JSON and add it as individual records or

b) save the file to file-system and store it's path.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216