Giter Site home page Giter Site logo

psbuiyrfirstandroiddbappsqlite's Introduction

psbuiyrfirstandroiddbappsqlite

##3. The User Interface ###1 Building the User Interface for the Todos App some great websites

<resources>
<color name="colorIcons"></color>
</resources>

select a new icon name playlist-play, copy vector code

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:width="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path android:fillColor="#000" android:pathData="M19,9H2V11H19V9M19,5H2V7H19V5M2,15H15V13H2V15M17,13V19L22,16L17,13Z" />
</vector>

then in res drawable,create a file called playlist_play.xml

####06:20 strings.xml

<resources>
<string name="app_name"</string>
<string-array name="categories_array">
  <item>Home</item>
  <item>Work</item>
</string-array>
</resources>

####08:04

final ListView lv = (ListView)findViewById(R.id.lvTools);
lv.setAdapter(new ArrayAdapter<String>(this,R.layout.todo_list_item,R.id.tvNode.itemname));
lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){});

TodoActivity.java

Intent intetn = getIntent();
String content = intent.getStringExtra("Content");
EditText editTOdo = (EditText)findViewById(R.id.editTodo);
eeditTodo.setText(content);

##4. Modeling Your Data Schema with Classes ###1 SQLite and Android

insert() update() delete() query()
execSQL() rawQuery()

###2. The Contract BaseColumns

public static final class TodosEntry implements BaseColumns{
}

###3 The SQLiteOpenHelper Class

import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper{
}

###4 Creating the Database in
TodoListActivity.java

protected void onCreate(Bundle savedInstanceState){
    DatavaseHelper helper = new DatabaseHelper(this);
    SQLiteDatabase db = helper.getReadableDatabase();
}

cmd

sqlite3 app.db

some commands

.tables
PRAGMA TABLE_INFO(categories);

###5 Inserting Records

ContentValues values = new ContentValues();
values.pput(TodoEntry.COLUMN_TEXT,"call");
long todo_id = db.insert(TodoENtry.TABLE_NAME,null,values);

###6 Reading and Writing

String[] projection = {"text","created"}
String selection = "category=?";
String[] selectionArgs = {"1"};
Cursor c = db.query("todos","projection,selection,selectionArgs,null,null,null);

is same as

select text, created from todos where category=1;

##6. Interacting with Data Asynchronously ###1 Asynchronous Data Handling in Android ####03:15 onCreate

getLoaderManager().initLoader()

onCreateLoader()
return a CursorLoader object

onLoadFinished(), onLoadReset

  • swapCursor()

###2 Using the CursorAdapter

Cursor c = getContentResolver().query(TodosEntry.CONTENT_URI);

then

final ListView lv = (ListView)findViewById(R.id.lvTodos);
lv.setAdapter(new ArrayAdapter<String>(this,R.layout.todo_list

TodosCursorAdapter.java

int textColumn = cursor.getColumnIndex(TodosContract.TodosEntry.COLUMN_TEXT);
String text = cursor.getString(textColumn);

psbuiyrfirstandroiddbappsqlite's People

Contributors

rengokantai avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.