[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Android App Development for Beginners – 54 – Testing the SQLite App
by
Tags:
Comments
49 responses to “Android App Development for Beginners – 54 – Testing the SQLite App”
-
There are two Problems he didnt mention, after that my Code worked like his
1st Problem c.moveToNext(); is misssing:
public String databaseToString() {
String dbString = "";
SQLiteDatabase db = getWritableDatabase();
String query= "SELECT * FROM " + TABLE_PRODUCTS + " WHERE 1";Cursor c = db.rawQuery(query, null);
c.moveToFirst();while (!c.isAfterLast()) {
if (c.getString(c.getColumnIndex("productname")) != null) {
dbString += c.getString(c.getColumnIndex("productname"));
dbString += "n";
c.moveToNext();
}
}db.close();
return dbString;}
and 2nd Problem, a comma is missing in on Create :
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {String query = "CREATE TABLE IF NOT EXISTS " + TABLE_PRODUCTS + " ( " +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_PRODUCTNAME + " TEXT" +
" );";sqLiteDatabase.execSQL(query);
}
-
great and love
-
I found a cool app that makes your phone yell when its moved, you can make it also ring when its moved so its less weird. But its kinda funny, and actually kinda helpful at keeping people from moving your phone without you knowing. Its called yelling phone. link below if you want it, or you can just search for it in the play store. https://play.google.com/store/apps/details?id=com.josco.yellingphone&hl=en
-
getting no table created error
-
The delete does nothing for me. I changed the code to DELETE FROM TABLE_PRODUCTS and that works fine. But I can't delete a single row.
-
thanks sir
-
I have learnt from bucky's tutorials (both java and android) and finally made these apps:
Give them a try Bucky !
https://play.google.com/store/apps/details?id=com.kometdevelopments.mycalculator
https://play.google.com/store/apps/details?id=com.kometdevelopments.mynotepadThank you bucky for everything..!!
You are really awesome man..!! -
Hi, I have a great problem with my new laptop. I cannot run an emulator because of the AMD processor. I have tried with arm-x86 instead of x86 but it didn't work. Can somebody help me?
-
ActionBarActivity is deprecated now..What should I do? 🙁
-
you're just awesome dude!!
-
whats is the use of "" in db.execSQL("DELETE FROM "+ TABLE_PRODUCTS + " WHERE " + COLUMN_PRODUCTNAME + "="" + productName + "";");
-
two things to consider
=> in while loop add c.moveToNext(); for cursor
=> in create table add "," (comma) after auto increment -
It shows FATAL EXCEPTION….not working.
-
Fairly large amount of errors here… regrettable that they haven't been mentioned in any of the videos. Relying on the viewers to point these out is lazy!
-
My working GitHub repo https://github.com/krabbypattified/AndroidSQLite
-
My App crash when i'm running
-
Is there any alternative way to save data because i couldn't understand the last tutorial at all ?
and by the way I am not familiar with SQL -
I'm having issue with while (!cursor.isAfterLast()) {
if (cursor.getString(cursor.getColumnIndex("_productname")) != null) {
dbString += cursor.getString(cursor.getColumnIndex("_productname"));
dbString += "n";
}
cursor.moveToNext();
}
cursor.close();
Its giving me error that if (cursor.getString(cursor.getColumnIndex("_productname")) != null) is going to -1 and thus crashing my program. Anyone why this is happening?
-
If you are having errors, the following code should work. This resolves both the SQLite syntax error & the infinite while loop.
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String query = "CREATE TABLE " + TABLE_PRODUCTS + "(" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_PRODUCTNAME + " TEXT " +
");";
sqLiteDatabase.execSQL(query);
}
…
public String databaseToString() {
…
while (!c.isAfterLast()) {
if (c.getString(c.getColumnIndex(COLUMN_PRODUCTNAME)) != null) {
dbString += c.getString(c.getColumnIndex(COLUMN_PRODUCTNAME));
dbString += "n";
}
c.moveToNext();
}
c.close();
…
} -
my app is closing automatically after clicking the button any help
-
As of Jan 30th 2017, This doesnt exist in the comments but after nearly 40 mins of searching, I found out that we need a comma in a part of the SQL code. Probably a new change to how SQLite works as noone else here has that issue.
http://stackoverflow.com/questions/31945925/android-sqlite-app-crashing -
Can anyone help me how i can include the entire bible/ very large data in the database and look it up from my app?
-
Hi Bucky,
Thanks for sharing this.One short question tough, how do you relate to DatabaseToString while it still in the grey text? I used your program in my Android Studio, but it couldn't be called in the Main Activity?
Thanks
Regards
Idham -
How do I attach a Database to my app which already contains the data that will be shown to the user. The user cannot manipulate it.
I am trying to make an Android App for a project which shows the season list and episode list of Sherlock. Instead of creating a new Activity for each episode I need to store all the details of the episode(summary, rating, image,etc) in a database and use it from there. -
sooo, the new version doesn't have EditText right?
-
the function printdatabase is not worcking right… is making my app to crash
-
Can a Column contain an array of Values. For eg. if the Column is for Model Names
of Cellphones that the people in the previous Column held, is it possible to list all the cellphones in one single Column. -
If you are having problems:
Make sure that in the databaseToString() method you pass COLUMN_PRODUCTNAME to the method getColumnIndex(), instead of just the required string like Bucky did. It's bad practice and leads to an error if you forget the underscore in front of the string like I did.
-
All the errors from missing the space in SQL queries ORZ
-
Can someone help me out? I can't understand this error. when i press the add or delete button the app will crash:
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.benazzatoandrea.myapplication, PID: 2629
java.lang.IllegalStateException: Could not find method addButtonClicked (MainActivity)(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'button'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22260)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.I am sure I selected the right method on the onClick option in the layout xml.
-
my program doesnt run, "unfortunately mysqlite has stopped" then i saw this
in the log" failed to connect to host (unix stream)" can anybody help 🙁
-
I liked this one. Props to ZEROgringo for identifying the infinite loop issue. I dumped my version of Bucky's implementation on my git at https://github.com/robertlagrasse/SQLite.
I commented through every line, so it's easy to see what's going on. Or you can just copy/paste if you're trying to get something off the ground quickly.
I also threw together a version2 and branched it. It just takes a second field, and adds a column to the database so the expansion process becomes a little more obvious.
Peace out, coding homies.
-
Please, help ?
When I click on the add button, it shows only the last input, it`s not showing all of them.
One more thing: when I open the application again, shouldn`t the old names be stored on the database? I added the printdatabase() method on the onCreate mathod of the MainActivity but it doesn`t show =(
Thank you! I`vee been following your tutorials and they`re great!
-
2:08 why not just make the constructor take only a context, considering all the other variables are constants?
public MyDBHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
} -
this is buckys github profile u can download almost all tutorials from here
https://github.com/buckyroberts/Source-Code-from-Tutorials
hope it helps to find the errors -
this is buckys github profile u can download almost all tutorials from here
https://github.com/buckyroberts/Source-Code-from-Tutorials
hope it helps to find the errors -
Amazing Tutorial on Sql in android !! Thanks a lot Bucky
-
activity not launching
plz help .. -
My app doesn't open only after this code and it says "Unfortunately SQLiteSample has stopped 🙁 Please help
-
whenever i click add or delete button the app gets force stopped, i tried looking into logs and found this ="
7/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.shivrajpatil.logintry, PID: 28427
Theme: themes:{default=overlay:com.your.theme.template, com.android.systemui=overlay:com.your.theme.template}
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
at com.example.shivrajpatil.logintry.Nextactivity2$1.onClick(Nextactivity2.java:26)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21158)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)"
any solution for this problem?? -
it's great.I want to add something into my db and i will get them to show in a textview when i restart it ,what am i supposed to do?
-
how to create a list of search to action bar ;
-
I was follow and make sure all the coding are correct, no errors. The apps can run but when I press on the button, it stopped automatically. Anyone face this problem and what is the solution. Thanks
-
How would you add another EditText to this example.
-
So I modified your code a bit and added 2 more EditText's.. I think I am good to go except they wont show up on the TextView. Here is the complete source code, http://pastebin.com/1KKQ4fVR
-
Hi 🙂
First of all I really like your vids 😀 and thet are very helpful.
But I habe a question.
I having problem with storing safely data I mean I'm developing an app which would have to save datas onto the phone but I want to protect it so after publushing and installing nobody can change the .db file or chanhe it to another file ("or be hacked") My apps ideia is that when you achieve smth you will get payed amd it is a very simple app so in my opinion it can be hacked easily so thats why I want to save the database and even not be replaced… There is a plan B that I have to use a log in system and online sql db but I think it is ridiculous for a simple app like this 😀
I hope someone can help me.
Thank you guys 🙂 -
Anyone having problems with deleteProduct() not working check that you are on MainActivity.java you are saving buckysInput to inputText instead of buckysText. Had me finding the answer for a while..
-
How do I apply all of those tuto about MySQL in a List View ?
Leave a Reply