Can't find SQLite database (db3) file on my phone - sqlite

I am creating an android app using xamarin shared project.
I have created a database using SQLite to store user's username, password, email, and other information.
This is my code to create SQLite code but it doesn't matter bc I know it works. User can signup, login, go to home page where they can see list of user's information. This means I am able to select and insert data from UserDatabase.db3 database.
var fileName = "UserDatabase.db3";
var documentPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentPath, fileName);
var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
var connection = new SQLiteConnection(platform, path);
Issue is that I can't see or find UserDatabase.db3.
What I can tell is SQLite database is store on user's phone and .db3 file is hidding under location
/Data/Data/com.companyname.AppName/File/
on google it said that some how I need to root my phone(What ever that means). But shouldn't there a way to see this find without rooting? maybe a desktop software that can access .db3 without rooting junk?
I also tried the following but db3 file was no where to find
Visual Studio > View > Tool Windows > Device File Explorer
If There is not other way to access my db3 file, than maybe there is a work around?
i guess I can just create a test page in my app where it display tables by using 'select' statment? Is this a good approch?

if you want to see your database,click on device file explore in Android studio->Click On Data->Click On Data->Click On "Your Package Name"->Click On Database->Here You Can See Your Database

Related

How to pass db path name in new SQLiteConnection in UWP?

I am working with Sqlite db in uwp, I am able to create db successfully without any issue in Local folder of my app.
But when I try to create in other places, I get error as
"SQLite.Net.SQLiteException: 'Could not open database file: E:\Users\PC3\Pictures\Abcd\MyDbFolder\mydb.sqlite (CannotOpen)"
I got the path string using StorageFolder.Path which I got through Folder picker, then I added it to FutureAccessList too. Though not works. Since the New db connection method expects the path, I am struggling for a long time, to use path in the Constructor.
//DbPathFromFAList = foldername.path (got from FutureAccess List) + mydbName.sqlite;
sqliteConn = new SQLiteConnection(new SQLitePlatformWinRT(), DbPathFromFAList);
As Rob said in this thread,
SQLite uses paths not streams and bypasses the file broker. It's database has to be in application data so the app has direct read/write permissions or install dir for read only.
You could not pass the path string parameter such as D: E: to SQLiteConnection method, even though you have used FilePicker to get the full file's permission.
In general, we use LocalFolder to store db file that could access directly.
DbFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Sqlite.db");
sqliteConn = new SQLiteConnection(new SQLitePlatformWinRT(), DbFilePath);
And the specified path is located at:
C:\Users[Your User Name]\AppData\Local\Packages[Your Package Name]\LocalState
You can not set it to the D or E disk. If you have used external database, please copy the db file to the local folder. for more please refer this document.

Where to Get Encryption Key for Realm App in Swift

I have a Swift app that uses the Realm Object Server running remotely on a Linux server. Everything is working, including real-time sync.
Occasionally I want to inspect the contents of a local Realm file used by the iOS Simulator so I can do some debugging. When I browse here:
~/.../CoreSimulator/.../Documents/realm-object-server/<unique id>/
...and I try to open this file: realm%3A%2F%2F104%2E236%2E129%2E235%3A9080%2F%7E%2Fmyapp.realm
I get prompted with: Please enter a valid encryption key for this Realm file.
Where do I get this encryption key? I tried using the admin token from the server, but that doesn't appear to be working.
Also, can I turn off encryption everywhere? Or is it mandatory for any app using the Realm Object Server?
It is not possible to open the local version of a synced Realm file using the Browser (or anything else, for that matter). This is due to differing history types internally (but I won't go into that now). In order to inspect the contents of the Realm file, you have to open it using the previously defined syncURL. The browser will then download the file and show you the contents.
A few links on this topic:
https://github.com/realm/RealmTasks/issues/327
https://github.com/realm/realm-core/issues/2276
You may use old version of Realm Browser, please update it and check the result again.
Use Realm Studio instead which worked for me.
Here can download the file
byte[] key = new byte[64];
new SecureRandom().nextBytes(key);
String encryptionKey = byteArrayToHexString(key);
//encryptionKey is what you want byteArrayToHexString see
Log.d("test", "encryptionKey:"+encryptionKey);
byteArrayToHexString() method you can see:How to convert a byte array to a hex string in Java?

Saving SQLite to Documents Folder

I need to pick an underlying method of saving data collected in the field (offline and remote locations). I want to use the HTML5 Database with SQLite but I can I pick the location? So far, I haven't been able to accomplish that. Here is some sample code I was using:
var dbName = "";
var Dir = blackberry.io.dir;
var path = Dir.appDirs.shared.documents.path;
dbName = path + "/" + "databasetest.db";
var db = openDatabase(dbName, '1.0', 'Test', 50 * 1024);
I used an "alert()" to see the file was "supposedly" created, but when I opened the folder in Explorer I cannot find it. Not really sure why and hense my question.
My application is for data entry, without getting into specifics, user may end up collecting a lot or little data. But I want some way of downloading the SQLite database?
Is this the intention of the SQLite database, or will I have to use another solution?
Thanks!
Chris
The Web SQL Database specification was designed for browsers where it would not have been appropriate to allow web pages to access arbitrary file paths.
The intended way to download data is to upload it to a web server in the cloud.
If you want to know the file name of your database, try executing the PRAGMA database_list. (Whether your app can access that path is a different question.)

How to Store User Preferences in an Adobe Flex/AIR Application

What's the standard way of storing user preferences in a Flex application for AIR? I need to store simple parameters like lists of recently opened files, window positions and sizes etc.
my favorite way to do it is to combine a VO with LSO (local shared object). If you have a LOT of settings, this doesn't work too well. The advantage is that you get a strongly typed settings object which is therfore bindable and has code introspection and completion.
The cool thing is it's only about 5 lines of code to manage an LSO. In addition, it's also pretty easy to manage a local encrypted store if you want to store any sensitive data.
registerClassAlias("SettingsVO",SettingsVO); //This lets us store a typed object in LSO
var settings:SettingsVO;
var settingsSO = SharedObject.getLocal("settings");
//Check to make sure settings exist... if not, create a new settings object
if( settingsSO.size && settingsSO.data && settingsSO.data.settings){
settings = settingsSO.data.settings as SettingsVO;
}else{
settings = new SettingsVO();
}
Now if you want to save settings you simply do
settings.someSetting = "newValue";
settingsSO.data.settings = settings;
settingsSO.flush();
And this solution works on BOTH AIR and Flex in any browser. Newer browsers will delete this data when clearing cookies, so beware of that.
I think the most flexible way is to use a local SQLite database. It gives you unlimited, structured storage and encryption if needed. See Peter Elst's introduction if you want to get more info.
There is no "Standard" way, but there are a lot of approaches, all which boil down to storing the user's preferences, then loading them up at runtime based on some uesr credentials, then changing the app based on those preferences.
You may store them in a server side database, such as SQL Server or MySQL; then have flex call a service which queries the database and returns the data.
You may store them as Shared Objects, which are the Flash version of browser cookies. (I believe they work on AIR applications too). This can get cumbersome with lots of data.
You may store them in an XML document and throw them on the server. Conceptually this is not much different than storing them in a server side database; but could get very tedious if you have a lot of users.
You could also store them, in an AIR app, locally using a SQLite database. SQLite is an embedded database used in Adobe AIR.
I don't bother with any of the fancy stuff. Just store it in an xml file in the application directory. Done.
Filestream does throw an error if you try to store it using File.applicationDirectory. I just trick the program...
var trickFile:File = File.applicationDirectory;
var file:File = new File(trickFile.nativePath + mySettings.xml);
Air falls for it every time.

Create SQLite database on BlackBerry

Invalid path name. Path does not contains a proper root list. See FileSystemRegistry class for details.
I want to create a DB in appication folder.I created a folder in res folder. I tried to access this folder(db) as:
URI dbURI = URI.create("file:///res/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("file:///db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("/res/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
URI dbURI = URI.create("/db/MyDB.db");
Database database = DatabaseFactory.create(dbURI);
I also tried to create SDCard directory on simulator and give this path. None of them worked for me. Please help me.
Your res/ directory is for things you want to add to the project, but as far as I'm aware you can't create files inside of it after you've deployed. Regardless, what you should probably do is either create it in a folder on the user's device (probably file:///store/), or on the SD card (file:///SDCard/).

Resources