I am assuming that the file is named: crimeBase.db
private static final String DATABASE_NAME = "crimeBase.db";
however, a search does not return any results?
I am assuming that the file is named: crimeBase.db
private static final String DATABASE_NAME = "crimeBase.db";
however, a search does not return any results?
where is the database file from chapter 14 created?
Hello,
run the app and you can check .db file from Android Studio>Tools>Android>Android Device Monitor.
Then, you will see File Explorer tab in a right panel that contains a data folder.The data folder includes your db you created.
However, if you can’t open the data folder or you can’t see anything in the data folder, I will explain another solution.
The solution is complicated. So I thought it would be true to not explain here.
OR
you check your code again, also you will create a table in your db and complete the coding and before run app, you can check to using try catch statement.
Iscodex
I found the db file in the device monitor like you said
however, I cannot see the data in the db file - i.e. if I double click on the db file nothing happens
is that correct?
thanks
lscodex
August 9 |
Hello,
run the app and you can check .db file from Android Studio>Tools>Android>Android Device Monitor.
Then, you will see File Explorer tab in a right panel that contains a data folder.The data folder includes your db you created.
However, if you can’t open the data folder or you can’t see anything in the data folder, I will explain another solution.
The solution is complicated. So I thought it would be true to not explain here.
OR
you check your code again, also you will create a table in your db and complete the coding and before run app, you can check to using try catch statement.
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
Okay, but you don’t forget that these sources want to root for mobiles or emulator devices.
Firstly, you should look over source this
then, If you don’t see something like that. You should try to another source that I wrote below.
Secondly, you should look over the source this
Lastly, I tried to Emulator Device and it’s worked for me
I don’t know which system to you used but the terminal is entering into work. I use windows OS. So I explained it through this operating system.Whatever…
find a path that Android/sdk/platform-tools.I found it Users/AppData/Local/Android but maybe you can find it the folder in ProgramFiles/Android/sdk/patform-tools.I don’t know why it happened.
I could not make the files root. (My research is still ongoing.), But if you want to see your db folder, you should follow me,
1- I run cmd as administrator and
cd users\username\AppData\Local\Android\sdk\platform-tools
2- C:\Users\username\AppData\Local\Android\sdk\platform-tools>adb devices
cmd: List of device
emulator-xxxx device ------ > This is your device and then,
3- C:\Users\username\AppData\Local\Android\sdk\platform-tools>adb -s emulator-xxxx shell
4- shell: generic_x86:/ $ cd <package_name for example (com.bignerdranch.android.criminalintent)>
5- generic_x86:/data/data/com.bignerdranch.android.criminalintent $ cd databases
cache databases
6-generic_x86:/data/data/com.bignerdranch.android.criminalintent/databases $ ls
crimeBase.db crimeBase.db-journal
Ok, here is db.
I see that there is a db.execSQL(“create table” ) command in the CrimeBaseHelper.java onCreate() function
How does the application only create the crimes table on the first run and not destroy that data on subsequent runs?
I am trying to duplicate this logic in my own application for school and am trying to figure out what code needs to be copied and where.
Should I just copy the entire database folder, and then change the names for my database file in the code?
private static final String DATABASE_NAME = “crimeBase.db”; public static final String NAME = “crimes”;
Thanks
Iscodex
I found the db file in the device monitor like you said
however, I cannot see the data in the db file - i.e. if I double click on the db file nothing happens
is that correct?
thanks
lscodex
August 9 |
Hello,
run the app and you can check .db file from Android Studio>Tools>Android>Android Device Monitor.
Then, you will see File Explorer tab in a right panel that contains a data folder.The data folder includes your db you created.
However, if you can’t open the data folder or you can’t see anything in the data folder, I will explain another solution.
The solution is complicated. So I thought it would be true to not explain here.
OR
you check your code again, also you will create a table in your db and complete the coding and before run app, you can check to using try catch statement.
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
Firstly, CrimeBaseHelper.java extends SQLiteOpenHelper so what does it mean?
SQLiteOpenHelper is important. This is because it is a helper class to manage database creation and version management.
you can check this source
you can see that "CREATION AND VERSION management."
So, SQLiteOpenHelper includes two methods that important.
1 - onCreate method in CrimeBaseHelper.java class runs execSQL() method to create your db and for use it. execSQL() method needs a query for tables (for example create, delete(remove), insert etc.).
you can check this source
2- onUpdate method in CrimeBaseHelper.java class has updating database If there is a change in the table as you want.
of course, these are basic explain but I suggest, you should learn that how to write sql commands and adapt to java code. (Cursor, ContentValues etc.)
And keep in mind that, When you delete your app in android device, Android will delete the database associated with that app. then android rebuilds the database when you install again the apps.This is so simple. So, yes, If you will duplicate this logic in your own practice at your school, you can change everything of the code in Java and run it.Maybe you don’t need to find the database folder (crime.db.).
why do I always get this error
java.sql.SQLException: No suitable driver
when I try to use this code
private Connection connect() {
// SQLite connection string
String url = “jdbc:sqlite:D:\DB\MHDB.db”;
Connection conn = null;
try {
conn = DriverManager.getConnection(url);
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
return conn;
}
I have both the database file and the jar file in that folder
D:\DB\MHDB.dbD:\DB\sqlite-jdbc-3.18.0.jar
thanks
lscodex
August 12 |
Firstly, CrimeBaseHelper.java extends SQLiteOpenHelper so what does it mean?
SQLiteOpenHelper is important. This is because it is a helper class to manage database creation and version management.
you can check this source
you can see that “CREATION AND VERSION management.”
So, SQLiteOpenHelper includes two methods that important.
1 - onCreate method in CrimeBaseHelper.java class runs execSQL() method to create your db and for use it. execSQL() method needs a query for tables (for example create, delete(remove), insert etc.).
you can check this source
2- onUpdate method in CrimeBaseHelper.java class has updating database If there is a change in the table as you want.
of course, these are basic explain but I suggest, you should learn that how to write sql commands and adapt to java code. (Cursor, ContentValues etc.)
And keep in mind that, When you delete your app in android device, Android will delete the database associated with that app. then android rebuilds the database when you install again the apps.This is so simple. So, yes, If you will duplicate this logic in your own practice at your school, you can change everything of the code in Java and run it.Maybe you don’t need to find the database folder (crime.db.).
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 11 |
I see that there is a db.execSQL(“create table” ) command in the CrimeBaseHelper.java onCreate() function How does the application only create the crimes table on the first run and not destroy that data on subsequent runs? I am trying to duplicate this logic in my own application for school and am…
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
can you tell me why this code would through this error?
java.sql.SQLException: No suitable driver
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname("org.sqlite.JDBC");
This was the standard procedure as far as I remember.
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
okay
I added that error to the try / catch and it got rid of the compile errorhowever, that error is thrown at run time
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
I restarted android studio to see if that would reset the environmentnow when I run it I get:
java.sql.SQLException: opening db: ‘D:\DB\MHDB.db’: open failed: EROFS (Read-only file system)
is this a windows 10 thing?
thanks
okay
I added that error to the try / catch and it got rid of the compile errorhowever, that error is thrown at run time
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
the other odd thing is that when I run the sample code from :D:\Android\14_LocalDatabases
it seems to work
I restarted android studio to see if that would reset the environmentnow when I run it I get:
java.sql.SQLException: opening db: ‘D:\DB\MHDB.db’: open failed: EROFS (Read-only file system)
is this a windows 10 thing?
thanks
okay
I added that error to the try / catch and it got rid of the compile errorhowever, that error is thrown at run time
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
it looks like 14_LocalDatabases adds a semi blank CrimeTable record during the add functionthen goes back and updates the corresponding fields later in the updateCrime function
is that correct?
thanks
the other odd thing is that when I run the sample code from :D:\Android\14_LocalDatabases
it seems to work
I restarted android studio to see if that would reset the environmentnow when I run it I get:
java.sql.SQLException: opening db: ‘D:\DB\MHDB.db’: open failed: EROFS (Read-only file system)
is this a windows 10 thing?
thanks
okay
I added that error to the try / catch and it got rid of the compile errorhowever, that error is thrown at run time
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
java.sql.SQLException: opening db: ‘D:\DB\MHDB.db’: open failed: EROFS (Read-only file system)
you think this may be caused because I have the D: drive hardcoded?
what would be the relative path equivalent?
thanks
it looks like 14_LocalDatabases adds a semi blank CrimeTable record during the add functionthen goes back and updates the corresponding fields later in the updateCrime function
is that correct?
thanks
the other odd thing is that when I run the sample code from :D:\Android\14_LocalDatabases
it seems to work
I restarted android studio to see if that would reset the environmentnow when I run it I get:
java.sql.SQLException: opening db: ‘D:\DB\MHDB.db’: open failed: EROFS (Read-only file system)
is this a windows 10 thing?
thanks
okay
I added that error to the try / catch and it got rid of the compile errorhowever, that error is thrown at run time
Thanks, I tried that, for some reason I always get this error:
Error:(42, 26) error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
lscodex
August 16 |
I think you can load the driver class before trying to obtain the connection.Maybe this code can help you.
Class.forname(“org.sqlite.JDBC”);
This was the standard procedure as far as I remember.
Visit Topic or reply to this email to respond.
In Reply To
mhenrydpai
August 16 |
can you tell me why this code would through this error? java.sql.SQLException: No suitable driver
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
hmm, there may be a lot of reasons.
I know that If you are running this code in an Android emulator then that environment may not be able to directly access the Windows file system. I found that maybe it helps you. Source
Or
maybe you change to file location where you know that you’ll have read/write permissions on the file.
Or
I don’t know what you wrote in your code but in the android studio, maybe, you should check AndroidManifest.xml file and you must be sure whether permission.(internal storage or external storage etc.)
Or
you should check this example
When I am in Android Studio and start up the emulator, then click Tools / Android Device Monitor
It gives me a message box that says:
Disable ADB integration - the following debug sessions will be closed: App
Yes / No
What does that mean exactly ?
Thanks
lscodex
August 17 |
hmm, there may be a lot of reasons.
I know that If you are running this code in an Android emulator then that environment may not be able to directly access the Windows file system. I found that maybe it helps you. Source
Or
maybe you change to file location where you know that you’ll have read/write permissions on the file.
Or
I don’t know what you wrote in your code but in the android studio, maybe, you should check AndroidManifest.xml file and you must be sure whether permission.(internal storage or external storage etc.)
Or
you should check this example
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
when I run my app in android studio emulator, then click android device monitor, I can see my entry under devices:
com.michaelalanhenry.www.lawncare
however, clicking on this entry does not seem to effect the data being displayed in the right hand side, i.e. File Explorer
how can I find the specific entry I am looking for?
thanks
lscodex
August 17 |
hmm, there may be a lot of reasons.
I know that If you are running this code in an Android emulator then that environment may not be able to directly access the Windows file system. I found that maybe it helps you. Source
Or
maybe you change to file location where you know that you’ll have read/write permissions on the file.
Or
I don’t know what you wrote in your code but in the android studio, maybe, you should check AndroidManifest.xml file and you must be sure whether permission.(internal storage or external storage etc.)
Or
you should check this example
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
this is what shows up in the android studio console
08/17 08:51:30: Launching app
$ adb install-multiple -r D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_3.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_9.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_2.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_0.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\dep\dependencies.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_1.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_7.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_4.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_8.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_5.apk D:\YSU\Summer\LawnCare\app\build\intermediates\split-apk\debug\slices\slice_6.apk D:\YSU\Summer\LawnCare\app\build\outputs\apk\app-debug.apk
Split APKs installed
$ adb shell am start -n “com.michaelalanhenry.www.lawncare/com.michaelalanhenry.www.lawncare.MainActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Connecting to com.michaelalanhenry.www.lawncare
Connected to the target VM, address: ‘localhost:8629’, transport: ‘socket’
Disconnected from the target VM, address: ‘localhost:8629’, transport: ‘socket’
when I run my app in android studio emulator, then click android device monitor, I can see my entry under devices:
com.michaelalanhenry.www.lawncare
however, clicking on this entry does not seem to effect the data being displayed in the right hand side, i.e. File Explorer
how can I find the specific entry I am looking for?
thanks
lscodex
August 17 |
hmm, there may be a lot of reasons.
I know that If you are running this code in an Android emulator then that environment may not be able to directly access the Windows file system. I found that maybe it helps you. Source
Or
maybe you change to file location where you know that you’ll have read/write permissions on the file.
Or
I don’t know what you wrote in your code but in the android studio, maybe, you should check AndroidManifest.xml file and you must be sure whether permission.(internal storage or external storage etc.)
Or
you should check this example
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.