-1

I am building an Ionic 4 App + PouchDB, I have built the app by executing the command ionic cordova run android and for a few days, it works well. Recently though, the app just won't open anymore and I have no idea how to check what went wrong.

Prior to this, whenever something went wrong in the app, I am able to check it using the chrome://inspect. However, with the app not being able to open at all, it's impossible to check the cause of the problem since I am also unable to check using chrome://inspect.

When I tried to run it using ionic cordova run android -l, I get the same result, which is the app loads and closes a few moments later, and I'm still unable to get into chrome://inspect.

I had a hunch that it has something to do with PouchDB. The app starts to behave this way when the storage is almost reaching 200mb. Upon reading the PouchDB FAQ, it's stated;

In PhoneGap/Cordova, you can have unlimited data on both iOS and Android by using the SQLite Plugin.

But I am already using the SQLite Plugin for PouchDB, I have used cordova-sqlite adapter for my PouchDB too. Below is an example of line in my code:

this._userdb = new PouchDB('user.db', { adapter: 'cordova-sqlite'});

With the app being unable to open, I'm out of ideas on how to retrieve the data stored inside PouchDB since I can't even get into the chrome://inspect at all (I can't see any console.log() for the stored data).

I feel like clearing the app data would allow the app to be opened as how it used to be but I really need to do a backup of the data stored inside PouchDB but I really have no idea how other than getting the console.log() of the data.

Is there any other way I can access the data stored inside the PouchDB to do the backup?

dyrnjrdz
  • 31
  • 4

1 Answers1

0

After many failed attempts to figure out how to retrieve the data stored inside PouchDB , I found one solution which is to pull the APK and extract the backup file.

By referring to this article, open CMD and shell into your device by;

adb shell

Provided that you know the app's package name, proceed to pull the APK by running;

adb backup -noapk com.app.your.package.name

**Note: Some devices like Samsung Galaxy stock Android 11 requires password to 'Backup my data'

Once pulled, you will find a backup.ab file and you need to extract this file. At this step, as a Windows user, I was unable to use the openssl method. I get an error using Python too.

But I found a solution that worked well for a Windows user. According to that solution;

  1. Download Android Backup Processor
  2. Go into the directory android-backup-tookit\android-backup-processor\executable (this directory should have a abp.jar file
  3. Copy your backup.ab into this directory.
  4. Open CMD, and run;
java -jar abp.jar unpack backup.ab test.tar
  1. If the device was required password during the backup process, you will be asked to enter password. Enter the same password you provided during backup. Be sure to read the README for further details.
  2. Once done, you will find test.tar file in the same directory. To view the file, simply extract it. The databases created inside the app should be in \test\apps\com.yourappname\f. The sqlite databases files can be viewed using DB Browser for SQLite.
dyrnjrdz
  • 31
  • 4