DBHelper.java

package com.icss.DBHelper;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;/*** 建立一个数据库帮助类*/public class DBHelper extends SQLiteOpenHelper { // download.db-->数据库名 public DBHelper(Context context) { super(context, "download.db", null, 1); } /** * 在download.db数据库下创建一个download_info表存储下载信息 */ @Override public void onCreate(SQLiteDatabase db) { db.execSQL("create table download_info(_id integer PRIMARY KEY AUTOINCREMENT, thread_id integer, " + "start_pos integer, end_pos integer, compelete_size integer,url char)"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { }}
下面看主界面的布局,在这里,我只设计了一个ListView来显示下载的音乐的名称,和一个开始下载按钮和一个暂停按钮。 布局文件如下: main.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1"> <ListView android:id="@android:id/list" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="0.70"></ListView></LinearLayout>
list_item.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayout2" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="5dip"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/tv_resouce_name" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="下载" android:id="@+id/btn_start" android:onClick="startDownload" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="暂停" android:id="@+id/btn_pause" android:onClick="pauseDownload" /> </LinearLayout></LinearLayout>

\



转载:http://www.adobex.com/android/source/details/00000435.htm

更多相关文章

  1. Android如何导入已有的外部数据库
  2. android 自定义toggle Button按钮
  3. android超炫button按钮动画效果
  4. SQlite Android 数据库应用程序系统
  5. Android studio RelativeLayout相对布局(控件相对父控件摆放-左上
  6. android 通知 手机 媒体 数据库 更新
  7. 获得android下面,所有的数据库
  8. Android Studio UI布局
  9. android的数据库API操作

随机推荐

  1. android_intent
  2. Android文件下载
  3. Android版本检测\自动更新 (转的别人的)
  4. Android判断当前网络类型是否为5G
  5. Android(安卓)代码监控apk安装,卸载,替换
  6. Android(安卓)studio:Failed to create J
  7. android scroll view infinite scroll
  8. Android(安卓)Dev入门笔记
  9. android外部数据库的导入使用
  10. Android语音识别功能使用