商品展示,SQLite数据库的使用

这篇博客介绍了如何利用SQLite数据库开发一个商品展示案例。首先概述了SQLite的轻量级特性和四大特性,接着详细阐述了创建商品展示布局文件、商品实体类以及数据库操作的方法,包括增、删、改、查的实现。最后展示了相关的XML布局和Java代码片段。
摘要由CSDN通过智能技术生成

一,SQLite是轻量级数据库,

  1.优点为:占用资源少,运行时间快;

  2. 四个要素分别是:原子性,一致性,隔离性和持久性;

  3. 支持的五种数据类型:null、integer、real、text、和blob。

二。开发一个商品展示案例,将商品展示,并进行增、删、改、查操作。

具体步骤:

1、创建善品展示案例的布局文件(activity_main);

mainActivity

 

 

<?xml version="1.0"encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="cn.edu.bzu. shop.MainActivity"
>
    <LinearLayout
        android:id="@+id/addLL"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
>
        <EditText
            android:id="@+id/etName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="商品名称"
            android:inputType="text"
            android:layout_weight="1"
/>

        <EditText
            android:id="@+id/etAmount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="商品金额"
            android:inputType="number"
            android:layout_weight="1"
/>
        <ImageView
            android:id="@+id/ivAdd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="addGoods"
            android:src="@android:drawable/ic_input_add"
/>
    </LinearLayout>
    <ListView
        android:id="@+id/lvGoods"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/addLL"
></ListView>

</LinearLayout>


2、创建Listview Item布局

<?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值