ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 数据库 >> SQLite >> SQLLite保存单词到本地数据库中

SQLLite保存单词到本地数据库中(2/2)

来源:网络整理     时间:2015-09-28     关键词:

本篇文章主要介绍了"SQLLite保存单词到本地数据库中",主要涉及到方面的内容,对于SQLite感兴趣的同学可以参考一下: 写一个存储单词的demo。存储再SQLLite数据库中。步骤:1、布局:包括两个编辑框分别是单词和汉语意思,点击保存按钮,另一个是输入关键字进行查询的编辑框,点...

package lzl.edu.com.savewords;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by admin on 2015/9/26.
 */
public class MySQLHelper extends SQLiteOpenHelper {
    final String CRATE_TABLE = "create table mywords (_id integer primary key autoincrement" +
            " ,word , explain)";

    public MySQLHelper(Context context,String info,int version){
        super(context,info,null,version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //第一次创建时使用
        db.execSQL(CRATE_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //有新版本更新时使用
        Log.i("onUpgrade ", "db-----oldversion:" + oldVersion + ",new :" + newVersion);
    }
}
DialogActivity.java
package lzl.edu.com.savewords;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.Map;

public class DialogActivity extends Activity {

    private ListView mListView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.Activity_dialog);

        mListView = (ListView)findViewById(R.id.mylistview);
       Intent intent = getIntent();
        //获取intent中的数据
        Bundle data =  intent.getExtras();
        //将bundle中的数据强转成List集合
        ArrayList<>> arrayList =
                (ArrayList<>>)data.getSerializable("data");
        SimpleAdapter simpleAdapter = new SimpleAdapter(this,arrayList,R.layout.line
                ,new String[]{"word","explain"},new int[]{R.id.word,R.id.explain});
        mListView.setAdapter(simpleAdapter);
    }
}

SQLLite保存单词到本地数据库中SQLLite保存单词到本地数据库中

以上就介绍了SQLLite保存单词到本地数据库中,包括了方面的内容,希望对SQLite有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_182335_2.html

相关图片

相关文章