0% found this document useful (0 votes)
24 views1 page

String - XML: Resources String String String

The document contains code to create a SQLite database table on an Android application. It defines strings for the table creation statement, an insert statement, and a select statement. The main activity code opens the database, executes the creation and insert statements, then performs a query and iterates through the results to access the field values.

Uploaded by

rehan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

String - XML: Resources String String String

The document contains code to create a SQLite database table on an Android application. It defines strings for the table creation statement, an insert statement, and a select statement. The main activity code opens the database, executes the creation and insert statements, then performs a query and iterates through the results to access the field values.

Uploaded by

rehan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

STRING.

XML

<resources>
<string name="app_name">MySQLite</string>
<string name="create">CREATE TABLE IF NOT EXISTS tbl_student
(stu_id INTEGER PRIMARY KEY AUTOINCREMENT,
stu_name VARCHAR(50),
stu_add VARCHAR(100) NULL,
stu_gpa FLOAT);
</string>
<string name="insert">
INSERT INTO tbl_student
VALUES ('SOK visual',
'phnon penh', 4.0);

</string>
<string name="select">SELECT * FROM tbl_student</string>

</resources>

MAIN ACTIVITY

package com.example.rehan.mysqlite;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

SQLiteDatabase db = openOrCreateDatabase("Test", MODE_PRIVATE, null);

db.execSQL(getString(R.string.create));
db.execSQL(getString(R.string.insert));
Cursor result = db.rawQuery(getString(R.string.select), null );
result.moveToFirst();
while(result.isAfterLast()!= true){
result.getInt(0);
result.getString(1);
result.getString(2);
result.getFloat(3);

result.moveToNext();
}

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy