当前位置: 首页 > news >正文

微博营销网站源码做外贸有效的网站

微博营销网站源码,做外贸有效的网站,建设通类似网站,前端网页设计样例实训9 数据存储和访问 一、【实训目的】 1、 SharedPreferences存储数据; 2、 借助Java的I/O体系实现文件的存储#xff0c; 3、使用Android内置的轻量级数据库SQLite存储数据; 二、【实训内容】 1、实现下图所示的界面#xff0c;实现以下功能#xff1a; 1#xff…实训9  数据存储和访问 一、【实训目的】 1、 SharedPreferences存储数据; 2、 借助Java的I/O体系实现文件的存储 3、使用Android内置的轻量级数据库SQLite存储数据; 二、【实训内容】 1、实现下图所示的界面实现以下功能 1用SharedPreferences类当点击”写入xml文件”按钮, 把“输入你想写入内容”控件中的数据写入到login.xml文件中 2用SharedPreferences类当点击”读取内容”按钮, 把login.xml文件中的数据读到到一个TextView中,并显示内容 具体步骤 MainActivity源文件 package com.example.hahah;import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream;import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText;public class MainActivity extends Activity {private Button write, read;private EditText writeText, readText;private String fileName context.txt;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);write (Button) findViewById(R.id.btnwritexml);read (Button) findViewById(R.id.btnreadxml);writeText (EditText) findViewById(R.id.writecontent);readText (EditText) findViewById(R.id.readcontent);write.setOnClickListener(new OnClickListener() {public void onClick(View arg0) {write(writeText.getText().toString());}});read.setOnClickListener(new OnClickListener() {public void onClick(View arg0) {readText.setText(read());}});}public String read() {StringBuilder sbBuilder new StringBuilder();byte[] buffer new byte[64];int hasRead;try {FileInputStream fis openFileInput(fileName);while ((hasRead fis.read(buffer)) ! -1) {sbBuilder.append(new String(buffer, 0, hasRead));}} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}return sbBuilder.toString();}public void write(String str) {try {FileOutputStream fos openFileOutput(fileName, Context.MODE_APPEND);PrintStream ps new PrintStream(fos);ps.print(str);ps.close();try {fos.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (FileNotFoundException ex) {ex.printStackTrace();}}Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}} Activity_main源代码 TableLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthfill_parentandroid:layout_heightfill_parentandroid:orientationvertical android:stretchColumns2TableRowEditTextandroid:idid/writecontentandroid:layout_width0dp android:layout_heightwrap_contentandroid:layout_weight1.0 android:hint输入你想写入的内容 //TableRowTableRow Buttonandroid:idid/btnwritexmlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入xml文件 //TableRowTableRowEditTextandroid:idid/readcontentandroid:layout_width0dp android:layout_heightwrap_content//TableRowTableRow Buttonandroid:idid/btnreadxmlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text读取内容 //TableRowTableRow Buttonandroid:idid/btnwritetxtandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入login.txt文件 //TableRowTableRow Buttonandroid:idid/btnwritesqlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入数据库 //TableRow /TableLayout 运行结果截图 附注该专栏是博主上学时的实训项目可供访客练习与参考。代码质量不是很好但能实现仅供参考
http://www.hkea.cn/news/14332313/

相关文章:

  • 简单网站的设计与制作wordpress 漏洞 2014
  • 营销型网站有哪些类信号增强器设置网站
  • 做高性能的网站 哪门语言好网站优化什么意思
  • wordpress建站要钱吗域名注册官网免费
  • 网站搭建价格表自助搜优惠券网站怎么做的
  • 好的电商网站建设与维护意味着什么企业网站设计师
  • 网站后台上传木马教程网站域名年费
  • 四省网站建设印度购物网站排名
  • 国外免费psd网站销售网站排名
  • thinkphp3.2 企业网站源码建站之星视频
  • 浙江建设局网站首页wordpress歌曲
  • 河南河南省住房和城乡建设厅网站常州市新北区建设局网站
  • 代做电大网站ui作业网站建设进什么科目
  • 网站标题 关键词 描述之间的关系外贸公司网站开发步骤
  • 360网站建设网站地图怎么添加
  • 360ssp网站代做天猫网站建设基本情况
  • 网站篡改搜索引擎js杭州市网站推广
  • 做服装外贸哪个网站好一站式的手机网站制作
  • 网站可以用什么做重庆定制网站开发价格
  • 北京网站建设公司兴田德润活动广安们内网站建设
  • 国内付费代理ip哪个好灵宝seo公司
  • 旅游网站规划说明广告营销推广方案
  • 保定网站建设技术支持上海网站建设的价格是多少钱
  • 建设班级网站过程夫妻做网站
  • 中国站长网站兰州专业做网站的公司
  • 2008 iis asp配置网站金华网站建设网站
  • 饮料网站建设市场分析沈阳百度推广哪家好
  • 眼镜网站怎么做竞价汕头房产网站建设
  • 网站上线确认书锕锕锕锕锕锕锕好湿免费网址
  • 个人做外贸的网站那个好做无锡网站制作建设