2015/2016 In my university for the OOP course I had to build a project and this channel helped me the most. that time ProgrammingKnowledge had 2lakhs subscribers....now it's more than a million...5 years with this channel as a subscriber...I always find your tutorials the best, easy to understand, no bullshit or unnecessary explanation..and you talk slow...that's a huge help for slow learners like me. please keep making tutorials like this. I'm now studying in a German University..came from Bangladesh. Hope to build a career in Programming but this channel will always be the part of my success.
Just to let you know that i've created my first android application thanks to your videos. So thank you for this tutorial which is very well done !!!!!
Finally: your code is perfect, BUT the extended class ActionBarActivity were recently deprecated. ActionBarActivity is deprecated; use `AppCompatActivity` instead Thanks
Great tutorial! I guess to run it on your device! Not emulator. I spent half an hour testing it on the emulator. but it's always showed me "data not inserted", still, I don't know what's going on in emulator. but then I run the same code on my device it worked properly.
Nice tutorial with little mistakes, actually one is a big one. First you should start method names with lower case letters. And then the big thing is, you check if data is inserted by an if clause. But in the if condition, you set your boolean variable to true, which means that it will always say Data Inserted. If you want to compare values, you need 2 equals, so it has to be isInserted == true. BUT you never compare booleans like that. you just type if(isInserted) {...}, if you want to run the following code when your variable is true and if(!isInserted){...} if its false.
Hi, The database created fine. but when I insert the data for the first time, the data inserted. while populating the records , i'm not able find the data which was inserted first.
2 questions: 1) isn't MARKS integer type in previous video ? 2)" if ( isInserted = true ) " should be " if ( isInserted == true ) " or " if ( isInserted) " ? Regards
I don't think you've noticed but your if condition in the end basically changes any result coming from the isInserted function to true, because its boolean, you should phrase the condition to (isInserted) rather than be (isInserted=true), that really checks if its true or false, which it never is, please revise your tutorials
Thanks for the through and detailed video. I got one burning question. How do you work with float, long, double data type from Java to SQL ? SQL only seem to have REAL and I wasn't able to solve this puzzle yet.
Hello, very nice videos, helping me a lot, thanks! I would like to ask you, We can do that with a scanner code bars, I mean, send the code to the database and after that show on the screen in a list ? Do you where I can find the code for that?
the program runs now without any errors, but, when i insert data into the database, it says Data Inserted, but, when i go and check the contents of the database, there are no records inside the database. I ran the program several times and inserted a different record each time, but still, no data in the .db database when i open to check it..
For same method, My app keeps on crashing suddenly. The error found in logcat was "NullPointerException: attempt to invoke virtual method Boolean on null reference object in method AddData....." And the indicated line is "Boolean insertData = myDB.addData(newEntry);" I tried to handle with try catch but it always comes up in block whenever I hit add button in the app.. Please help.
Sir when I creating database it's working in android version 4.4 but it's not working 9 pie why. When I insert the data into table inserted successfully in 9 pie version . But when I checke the data in android monitor it's only showing database name nothing else.. Inside the database name no any column is showing . But the similar application working with android version 4.4 .. Please make the videos on this problem.
Great video ! I have one strange issue, when I add a new entry it gets created twice. The table contains two different ID's with the same data. Any idea ?
Hi. I followed all your instructions and while executing the app, I can't run it completely bc when executing this.getWritableDatabase() the app stops & I can't figure out why? What should I do ? Thanks
I tried using the exact same code and it's not showing the inserted data in DB Browser for SQLite is anything I want to deal with the emulator? i am using USB debugging to run my application
i wish you could do some tutorials using web-services to extract data from Mysql server. i tried quite a few of the available android tutorials on RUclips, None came close to what you are doing.
I already have a databse of what i want to add. I do not want to follow the insert procedure , how can i directly give my data to the table and display it ?
Hi its realy great thank you . I would like to ask you if its possible to use the same steps at eclipse application or we should do that just on android stodio thanks
I dOn't get it. Why is that your program still running even the Condition of if else statement in 11:25 is Set a value not equal to? Can you please explain it to me?
hi can u tell me how to validate user credential here i want do when click AddData button before validate like name surname etc.. boolean isInserted = myDb.insertData(editTextName.getText().toString(), editTextSurname.getText().toString(), editTextMarks.getText().toString())
If he made errors, how his program is running. Seems fishy. I have error Error:(46, 39) error: is not abstract and does not override abstract method onClick(View) in OnClickListener. Any idea?
If you guys are having problem with crashing down then this is the right comment to help you: db.execSQL("Create Table " + TABLE_NAME + "(B_id INTEGER PRIMARY KEY AUTOINCREMENT, B_title TEXT, B_author TEXT)"); In the line above you could have probably missed the extra Closing parenthesis. Hope this helps you guys, keep programming :)
Hi, in my DatabaseHelper.java I am getting a red squiggly line under the "put" method with the error message "non static method put cannot be referenced from a static context". How do I fix this? Thanks.
How do you put DATE and TIME in database? assmue to have DueDate as Col name and type is DATETIME, how will you gonna concatenate the date and time? by using textview wriiten in date (passed the value from the other) then concatenate the timepicker dialog chosen value?
I am a beginner just after running the project, when I checked database data folder in device monitor it contains nothing. Also when you created below coding? and is it necessary for just creating the table on db?. @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main,menu); return true; @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); return true; i am getting error on R.menu line
when I press the Add Data button the negative toast appear informing me that it's failed to be inserted in the database, I also checked the database manager and i found the table empty. I'm sure I did all the instructions properly. can anyone help me to find the where's the error and what's the solution??
Hi Guys! In My AS 2.2.1, under layout folder there are two .xml files: activity_main.xml (where such a statement “” is written) and content_main.xml. Which of the two is correct to have the source codes here been written? I'm informed that activity_main.xml is better because it is the layout for the MainActivity. Thank you all in advance.
how is it works in some app for example there is something like local DB and if you connect to internet it make something like update to main DB and update your local for next offline use? Whats that solution ?:P i cant imagine this
i want to add a "show" button..such tht on clicking tht button full database table will get displayed on screen..what should i do for this..how do i display table..?? can u plz explain..
what if i dont want duplicate values in my database and it should show an error if done so and i only have one column "name" in my db which is declared as unique, what should i do? please help and thank you
Please tell me how can I validate the data before insertion as it's executing insert query even if there is no data in EditTexts ? Thanks for sharing this tutorial it's excellent..
What if the database already exists on the device? Does you DatabaseHelper constructor overwrite/replace the existing database with a new one or will it just pull what's already existing?
there is a sql keyword called "exists" and can be used in if statement (in SQL not java) to detect if the data base exists or not, and can delete and recreate the database based on that. Research that keyword for more info
That extension is bugged, it didn't show any data but i checked database on inloop.github.io/sqlite-viewer/ it showed the data saved also i changed the version in super method from 1 to 2
+Xudong Ran hello...i got solution for this error...plz chk whether you hav typed create table's properly or not ?? thats the main issue I hd to resolve
anyone know a good video where you store EXISTING CONTACTS into a SQLite db? all of the videos i find are storing user "strings" into the db. I want to be able to pull the existing phone book including name / number & store into my own db.
public void onCreate(SQLiteDatabase db) { db.execSQL("create table " + TABLE_CONTACTS +" (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,surname TEXT,marks INTEGER)"); } i use this code .my application is not work properly(unfortunately app is stopped) can anyone please give the proper solution?
mainactivity.java is showing action_setting in red even after alt+enter no improvement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }
2015/2016 In my university for the OOP course I had to build a project and this channel helped me the most. that time ProgrammingKnowledge had 2lakhs subscribers....now it's more than a million...5 years with this channel as a subscriber...I always find your tutorials the best, easy to understand, no bullshit or unnecessary explanation..and you talk slow...that's a huge help for slow learners like me. please keep making tutorials like this. I'm now studying in a German University..came from Bangladesh. Hope to build a career in Programming but this channel will always be the part of my success.
Just to let you know that i've created my first android application thanks to your videos. So thank you for this tutorial which is very well done !!!!!
I am a beginner learning android and i found this tutorial helpful
You Rock this video really saved me, I am studying Android and was confused by the Database section Thank you!
Yes bro this happened to me also
Great tutorials, we like the way you elaborate on what every single code does in simple English
DUDE THIS THING WORKED LIKE A CHARM!
Your explanation is some other level!
Thanks
For Mac instead of ctrl+click use cmd+down arrow to go to the class and see it in its context. or ctrl+j for documentation.
Nice example. However when adding data to SQLite database, as soon as data is added you can reset the UI texts to blank.
Finally:
your code is perfect, BUT the extended class ActionBarActivity were recently deprecated.
ActionBarActivity is deprecated; use `AppCompatActivity` instead
Thanks
if (isinserted = true) // is always true because you force it
replace = by ==
nope , still didnt work
or you can simply type
if(isInserted) {} //for true
if(!isInserted} {} //for false
boolean == true; facepalm
Actually he's passing string to database helper constrictor, pass int, it should work
@@jakemacale9735 not working
Great tutorial!
I guess to run it on your device! Not emulator.
I spent half an hour testing it on the emulator.
but it's always showed me "data not inserted", still, I don't know what's going on in emulator.
but then I run the same code on my device it worked properly.
i spent the whole day repeating the code to check why it doesn't work for me until i found this comment shiiiiiit i don't know how to thank you,
Odd mine worked on an emulator (Pixel 2)
Nice tutorial with little mistakes, actually one is a big one.
First you should start method names with lower case letters.
And then the big thing is, you check if data is inserted by an if clause. But in the if condition, you set your boolean variable to true, which means that it will always say Data Inserted.
If you want to compare values, you need 2 equals, so it has to be isInserted == true. BUT you never compare booleans like that. you just type if(isInserted) {...}, if you want to run the following code when your variable is true and if(!isInserted){...} if its false.
Hi, The database created fine. but when I insert the data for the first time, the data inserted. while populating the records , i'm not able find the data which was inserted first.
Very nice teaching method, God bless you.
instead of using an if statement ; you can use ; return result != -1 and if(inserted==true) isnt necessary , replace it buy if(inserted)
You are Awesome i had problems before with android database and now they are all solved :):):):)
2 questions:
1) isn't MARKS integer type in previous video ?
2)" if ( isInserted = true ) " should be " if ( isInserted == true ) " or " if ( isInserted) " ?
Regards
if ( isInserted == true ) and if ( isInserted) are both correct
Despite doing exactly what has been done in the tutorial, every time I press the add button, I get a "data not inserted" message. How do I fix this?
Just clear the app data and reinstall the app.
I don't think you've noticed but your if condition in the end basically changes any result coming from the isInserted function to true, because its boolean, you should phrase the condition to (isInserted) rather than be (isInserted=true), that really checks if its true or false, which it never is, please revise your tutorials
exactly, that's why he didn't show at the end how he inserted the data
Thanks a lot for this series, it helped me out a lot
It's very helpful but how to insert multiple tables in one database ....I request you to say how to insert multiple tables in Database
Thanks for the through and detailed video. I got one burning question. How do you work with float, long, double data type from Java to SQL ? SQL only seem to have REAL and I wasn't able to solve this puzzle yet.
Thanks alot for this easiest tutorial ,it helped me alottttttttt
Awesome training..carry on guru
Hello, very nice videos, helping me a lot, thanks!
I would like to ask you, We can do that with a scanner code bars, I mean, send the code to the database and after that show on the screen in a list ? Do you where I can find the code for that?
the program runs now without any errors, but, when i insert data into the database, it says Data Inserted, but, when i go and check the contents of the database, there are no records inside the database. I ran the program several times and inserted a different record each time, but still, no data in the .db database when i open to check it..
Can this same coding be run in eclips?
If yes - then it is showing "Force Close". While i run this app.
For same method, My app keeps on crashing suddenly. The error found in logcat was
"NullPointerException: attempt to invoke virtual method Boolean on null reference object in method AddData....." And the indicated line is "Boolean insertData = myDB.addData(newEntry);"
I tried to handle with try catch but it always comes up in block whenever I hit add button in the app..
Please help.
db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,SURNAME TEXT,MARKS INTEGER)");
change to:
db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,NAME STRING,SURNAME STRING,MARKS INTEGER)");
MY ERROR STOPPED
Sir when I creating database it's working in android version 4.4 but it's not working 9 pie why.
When I insert the data into table inserted successfully in 9 pie version .
But when I checke the data in android monitor it's only showing database name nothing else..
Inside the database name no any column is showing .
But the similar application working with android version 4.4 ..
Please make the videos on this problem.
Thanks for this Tutorial, It helped me to Create Highscore Table in my game :)
Great video ! I have one strange issue, when I add a new entry it gets created twice. The table contains two different ID's with the same data. Any idea ?
Nice tutorial, but how to fetch the data in separate page instead of dialogue? Please help me.. Thank you.
you can just try/catch to see if the values are inserted, that would be much better
app unfortunately stopped
in Android sdk version 3.0.1
Hi. I followed all your instructions and while executing the app, I can't run it completely bc when executing this.getWritableDatabase() the app stops & I can't figure out why? What should I do ?
Thanks
brillliant tutorial sir........thanks for helping.........!!!!!!
I tried using the exact same code and it's not showing the inserted data in DB Browser for SQLite is anything I want to deal with the emulator? i am using USB debugging to run my application
Thanks man, very easy to follow, great tutorials.
in case I have more than 4 or five tables, how I will write data in the public boolean insertData() method?
I just want to say about this video.awesome!!!!
i wish you could do some tutorials using web-services to extract data from Mysql server.
i tried quite a few of the available android tutorials on RUclips, None came close to what you are doing.
thank you! I really like your tutorials. You are the best!
can i add through the sqlite manager/db browser for sqlite itself because my most inportant thing is to retrieve first then insertion comes later..
I already have a databse of what i want to add. I do not want to follow the insert procedure , how can i directly give my data to the table and display it ?
Sir I have a question
If I get number from user in sign up activity then how can I use that number in home activity plz tell me
Hi
its realy great thank you .
I would like to ask you if its possible to use the same steps at eclipse application or we should do that just on android stodio
thanks
your if condition at the onClickListener method is wrong use this instead if ( isInserted == true ){}
Good Observation!
I dOn't get it. Why is that your program still running even the Condition of if else statement in 11:25 is Set a value not equal to? Can you please explain it to me?
hi can u tell me how to validate user credential here i want do when click AddData button before validate like name surname etc..
boolean isInserted = myDb.insertData(editTextName.getText().toString(),
editTextSurname.getText().toString(),
editTextMarks.getText().toString())
If he made errors, how his program is running. Seems fishy. I have error
Error:(46, 39) error: is not abstract and does not override abstract method onClick(View) in OnClickListener.
Any idea?
If you guys are having problem with crashing down then this is the right comment to help you:
db.execSQL("Create Table " + TABLE_NAME + "(B_id INTEGER PRIMARY KEY AUTOINCREMENT, B_title TEXT, B_author TEXT)");
In the line above you could have probably missed the extra Closing parenthesis. Hope this helps you guys, keep programming :)
Very well explained, great work! Keep it up!
PLEASE HELP
When I click the button it says Data not inserted but I have the same code as video. I don't know what to do helpp!
Hi, in my DatabaseHelper.java I am getting a red squiggly line under the "put" method with the error message "non static method put cannot be referenced from a static context". How do I fix this? Thanks.
Great tutorial insertion success could have been ascertained using
return value == -1;
Rather than using an if statement
Nice Work...it helped me a lot...Thanks for sharing...
11:25 I think there is a typo-> "isInserted==true" is correct
Goodie. Every detail matters.
How do you put DATE and TIME in database? assmue to have DueDate as Col name and type is DATETIME, how will you gonna concatenate the date and time? by using textview wriiten in date (passed the value from the other) then concatenate the timepicker dialog chosen value?
make on video on how to insert image into sqlite database and retreive image from database in android studio
I am a beginner
just after running the project, when I checked database data folder in device monitor it contains nothing.
Also when you created below coding? and is it necessary for just creating the table on db?.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main,menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
return true;
i am getting error on R.menu line
thinks sir g very helpful territorial ......very impressive
I got Data not Inserted instead, and my database's table is empty. So it failed to insert the data right? Anyone know how to fix it?
Me too.. please explain anyone??
@@yedukrishnan5862 i got it fixed but i dont remember what it is. I think you should check your code again.
when I press the Add Data button the negative toast appear informing me that it's failed to be inserted in the database, I also checked the database manager and i found the table empty. I'm sure I did all the instructions properly. can anyone help me to find the where's the error and what's the solution??
same problem
Did you find the solution on this error. I get the same here... :-(
try adding permission in manifest file of read/write..!!
Hi Guys! In My AS 2.2.1, under layout folder there are two .xml files: activity_main.xml (where such a statement “” is written) and content_main.xml. Which of the two is correct to have the source codes here been written? I'm informed that activity_main.xml is better because it is the layout for the MainActivity. Thank you all in advance.
why is that only ID column appears in the Sqlite no name and marks even though i review your code. no data stored in my sqlite reply asap thanks
very nice, easy to learn, big thanks !
how is it works in some app for example there is something like local DB and if you connect to internet it make something like update to main DB and update your local for next offline use? Whats that solution ?:P i cant imagine this
i want to add a "show" button..such tht on clicking tht button full database table will get displayed on screen..what should i do for this..how do i display table..?? can u plz explain..
what if i dont want duplicate values in my database and it should show an error if done so and i only have one column "name" in my db which is declared as unique, what should i do? please help and
thank you
Please tell me how can I validate the data before insertion as it's executing insert query even if there is no data in EditTexts ? Thanks for sharing this tutorial it's excellent..
+dhruv sahni Yeah thats one thing he didnt explain but Im sure there are videos on that
What if the database already exists on the device? Does you DatabaseHelper constructor overwrite/replace the existing database with a new one or will it just pull what's already existing?
there is a sql keyword called "exists" and can be used in if statement (in SQL not java) to detect if the data base exists or not, and can delete and recreate the database based on that. Research that keyword for more info
i found the answer
@Override
public void onClick(View view) {
}
thank you for this tutorial, exactly what I was looking for
I used the same code and followed the same procedures, but the table is still not created. How can I create it?
very useful i can grab the flow of it
when i click on add date "Unfortunetely app is stopped" msg is displayed...can u please help where i do mistake
how do i do it for a spinner, iv created the spinner but i just want the options only from the spinner to go into my database
This is all very clear. Thank you.
in my case data were being added at the first time only then it's not inserting data why??
That extension is bugged, it didn't show any data but i checked database on inloop.github.io/sqlite-viewer/
it showed the data saved
also i changed the version in super method from 1 to 2
I was liking the tutorial BUT the main activity is created as an extension of a defunct class which ruined my experience
when i click on add date "Unfortunetely app is stopped" msg i received...plz help
+Mithilesh Bhalekar me too!!
+Xudong Ran hello...i got solution for this error...plz chk whether you hav typed create table's properly or not ?? thats the main issue I hd to resolve
+Arifin Firdaus db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,SURNAME TEXT,MARKS INTEGER)");
chk whether u hav entered dis properly or not ?
+Mithilesh Bhalekar my bad. I've changed MARKS TEXT to MARKS INTEGER now. Thankyou Mithilesh Bhalekar
+Arifin Firdaus 👍👍👍
Hello sir, i m not able to see the package for check to see wheather the connection is created or not how to di it i need help?
anyone know a good video where you store EXISTING CONTACTS into a SQLite db? all of the videos i find are storing user "strings" into the db.
I want to be able to pull the existing phone book including name / number & store into my own db.
if i keep adding numbers one after another , will it create multiple rows?
how to show automatically column ID (auto increment) into Edit Text when you input the data at the same time ?
Thank you! It was very useful. Gob bless you!
How do you access a string passed to a TextView to log to the database?
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_CONTACTS +" (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,surname TEXT,marks INTEGER)");
}
i use this code .my application is not work properly(unfortunately app is stopped)
can anyone please give the proper solution?
Sir how can i use SQLiteOpenHelper object out of MainActivity?
Thanks man Its working. thumps up.
mainactivity.java is showing action_setting in red even after alt+enter no improvement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
how to add the datepicker and radiobutton in the same database ?
Fantastic tutorials, thank you
u made a mistake in the last if
it should be == not =
ya this video is a waste, he never showed at the end that he was able to insert data
How do you change the text and ID's of the views like that ?
I get -1 result by which it return false. Please tell me how I fix it?
Can I run that in my phone? Coz my emulator is getting lag and hang