After installing Android App on device, app could not recognize database. - android

Apps runs fine on emulator, but the same does not on device(Samsung S5670). Its showing that the database is empty.
Should i need to upload databases separately or it is embedded in apk itself.
I have also check the File explorer in DDMS -> "Data" section could not find any data in it.
Do i need to make any other setting on device

I guess you didn't write the required SQLite helper class that initializes your database. Somehow once you managed to create the correct database on the emulator, so it works on that. Try uninstalling your app completely from you emulator, reinstall it, and see if it works. Only updating you app doesn't remove data associated with it on the device, so i doesn't affect your database, hence you need to uninstall.
If it stops working on you emu too, then you need to go look into your SQLite helper class.

Related

Ionic app suddenly won't open in Android 11

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?
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;
Download Android Backup Processor
Go into the directory android-backup-tookit\android-backup-processor\executable (this directory should have a abp.jar file
Copy your backup.ab into this directory.
Open CMD, and run;
java -jar abp.jar unpack backup.ab test.tar
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.
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.

Android - access Google Drive appdata folder from another device, but same app

My app is setup to allow backups to be saved to a Google Drive appdata folder. It all works perfectly well on the same device. When I make a backup, delete the app's data, then restore it all works.
However, when I try to backup on one device, then install on another and attempt to restore there are no files found. Same goes for when I uninstall the app on the original device, reinstall it on the same device and attempt to restore. Both cases result in no files being found despite the fact that I see there are files in the appdata folder when I log into Google Drive.
I read somewhere that you must use the RESOURCE_ID instead of the DRIVE_ID of a file for it to work between devices since a DRIVE_ID will be different from device to device. However the only way I've seen how to get the RESOURCE_ID is by using the driveId.getResourceId(), and I can't get the proper DRIVE_ID from another device.
tl;dr: how should I go about retrieving the proper file from the appdata folder that was created by another device/installation?
I have a database backup option in my app as well. I implemented it using the new Google Drive Android Api and what's more important, it works perfectly fine from one device to another.
Here's how I did it and what I recommend:
Before reading or writing anything to Google Drive, call requestSync to make sure everything is synchronized and up to date (see how to use it here).
Retrieve your files by name using a query instead of identifiers. As Google Drive allows multiple files with the same name, order your query by date and use the newest one.
To avoid creating multiple backup files with the same name, use a query to find if the backup file already exists on Google Drive and if it does, open it and overwrite it.
This is the point I guess you won't like: I recommend not using the Appfolder... for the moment. Google has acknowleged there might be some synchronization issues with it when uninstalling and reinstalling the app. I tried to use the Appfolder as well in my app without success and I finally ended up creating an ordinary folder in Google Drive. With that said, you can try the first three recommendations before adopting this one.
I hope these points can help with your implementation. If you need anything else, just tell.

Android, viewing SQLite database in runtime (not like other questions)

So i have been looking for this answer for the past 2 days. all of them want to know how to extract the database file .sql from the device your testing your app on. What i want to do is use a manager, like fire fox's sqlite manager, to open the location of the file and view the data base as information is being entered. I did this once when i was using titanium, but now have switched to eclipse. So what i want is, when i am running my virtual machine, android emulator, i want to fine the location that it is reading the sql file from. doing this i can open it with my fire fox manager and as info is going into the file the manager will show me whats going in and out. Basically i want to see real time info from my internal database, either from emulator or phone. PLEASE HELP!
Go to this link and get the SQLiteManager plugin for eclipse.

How to get DB file in android using debugging mode?

I make an application which cannot run in emulator. So I use android debugging mode or live running. It is running well on my device. and in that application, I create a database for user login. I want to see the data on my database. I mean I want get the database file, and access using a tools like sqlite manager to see the inside. the question is, how to get the database file?
Generally, if I using emulator, it places in data/data/com.package/databases/namedatabase(.db or without it).But when I connect my device in pc and running it, actually there are 3 directories, data, mnt, and system. When I was try to check the subdirectories of data, it is none. There is not any directory in it. so I can't get the database file.
I use eclipse.

Database created from SQLite Browser not working in device "Android"

My proble is I created a device in sqlite database browser and its work fine in emulator.
but when a try my application to my device it cause force close.
and when I remove the database and create a new one using eclipse it works fine even in my device. But inserting a lot of data in database 1 by 1 realy freakin me out so anyone know a sqlite database browser that also work for device??!
check out this tutorial for using database file in application.
Remember one thing that it only copy you DB file in application that's it.
On real device you don't have permissions to sqlite database. That's why you won't be able to browse database like you can on a emulator.
See this for a work around.
Tool to see android database, tables and data
If you want to create a pre-loaded DB outside of your app and use it in your app later, you will have to put it in your assets directory and then copy it to your apps storage space the first time your app is started.
This is due to the fact that as a security measure, on real (unrooted) devices nothing but your own app is allowed access to that apps databases directory (and certain other ones as well).
There is a good tutorial for creating/copying your own DB outside of the app and copying it to the apps databases directory here.

Categories

Resources