Operating SQLite databases in Android

Source: Internet
Author: User

I went back to my study on Android. I was so busy that I finally had almost time to do my own things. It was really amazing !! I wanted to write android controls and their monitors, but I checked the android manual and basically found it. However, it is troublesome to check some functions, such as TextWatcher in EditText.Interface. Generally, oneditexceptionlistener is found.Interface. Okay, you don't have to talk about it. Cut him first !!!!

------------------------ Giggling --------------------- giggling ------------------------------

After the project is created, it is mainly written into SQLite.

Next, let's add the background. Here, I wrote two classes in the first package. This is because I am switching two activities without affecting this experiment. This experiment is in OtherActivity. java.

  Sqlite     VERSION = 1 Sqlite(Context context,String name,(context, name,         System.out.println("create a Database"        arg0.execSQL("create table user(id int,name varchar(20))"  onUpgrade(SQLiteDatabase db,  oldVersion,         System.out.println("update a Database"

 com.yuyidong.db.Sqlite;

The previous TextView and Button (Call) should be ignored..

                                                                                                     

The statement is added to the listener.

  OtherActivity          == intenter.getStringExtra("hello"=== == == == == == 

Please ignore the Intent, text, and button objects.

Next, let's talk about the story.

 buttonListener   version = 1             
            button_check =
            (button_check=== Uri.parse("smsto:10086"= "sms_body", "Test good!"
             (button_check ==
 
=  Sqlite(OtherActivity.,"yyd_test_db"
                SQLiteDatabase db =
                Toast.makeText(OtherActivity., "Create" (button_check ==
                version++=  Sqlite(OtherActivity.,"yyd_test_db"=, "Update" (button_check ==  = 
                values.put("id", 1"name","zhangsan"=  Sqlite(OtherActivity., "yyd_test_db"=
                db.insert("user", , "Insert" (button_check ==
                Sqlite dbHelper =  Sqlite(OtherActivity., "yyd_test_db"== "name", "zhangsanfeng"

Db. update ("user", values, "id =? ", String [] {" 1 "Toast. makeText (OtherActivity.," Update_Table "}
(Button_check = {
Sqlite dbHelper = Sqlite (OtherActivity ., "yyd_test_db" SQLiteDatabase db = Cursor cursor = db. query ("user", String [] {"id", "name"}, "id =? ", String [] {" 1 "},,,


{
String name = cursor. getString (cursor. getColumnIndex ("name" System. out. println ("Get --->" +}
}
}

}

You can not only write a program to operate SQLite, but also use shell to operate SQLite databases.

Databases is available only after the database is created in the App. It is still different from the general relational database.

 

To sum up, SQLite is not recommended in apps, because it sometimes reports Errors for no reason, because it often occurs during testing, when the program is burned in for the first time, you can create the same database N times without any errors. If you open the database for the second time, the program will crash no matter which Button you click, including Insert, it won't be the first time, and the information in the data table can be found. The second time it won't work, and the query won't be able to afford it. It hurts.

 

 

 

Reprinted please indicate the source: http://www.cnblogs.com/yydcdut/p/3651977.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.