android程序调试和访问网络进行下载
来源:互联网 发布:彩票开奖数据api 编辑:程序博客网 时间:2024/06/05 07:24
1、开发视频调试程序。
logcat 和flex中的trace差不多。
2、SQLiteDatabase
File Explorer 可以通过pull和push 进行填入和输出一个文件。
3、对以sorry! The application sqlite has sttopped unexpectedly . 如何去查找问题的错误,需要日志log。
点击DDMS 中logcat中E W I D V 进行查看和分析。
$表示一个类的内部类,只要找到自己的包的出错的地方就能够找到异常。
4、对与日志的输出的方式,使用log类进行输出。
其中d表示调试信息,Log.d("myDebug","this is a debug");
在logcat中写入
lesson18 主要内容
1、使用http协议下载文件
2、将下载的文件写入sdcard中
创建一个HttpURLConnection urlconn = url.openConnection();
获得一个inputStream对象
urlconn.getInputStream()
android.permmison.INTERNET
HttpDownloader httpdown = new HttpDownloader();
httpdownloader.download("http://192.168.17.10")
public String download(String urlStr){
StringBuffer sb = new StringBuffer();
String line = null;
BufferReader buffer = null;
try {
//创建一个URL对象
url = new URL(urlStr);//java.net 包
HttpURLconnection urlConn = (HttpURLConnection)url.openConnection();
//使用io流读取数据
buffer = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));//z装饰模式
}catch (Exception e){
e.printStackTrace();
}finally {
try{
buffer.close();
}catch (Exception e)
{
e.printStackTrace();
}
}
return sb.toString ;
}
访问sdcard得设备sd卡的目录
Environment.getExternalStorageDirectory() 得到目录名
android.permission.WRITE_EXTERNAL_STORAGE //声明权限
public File write2SDFormInput(String path ,String fileName ,InputStream input){
File file = null
OutputStream output = null;
try {
createSDDir(path);
output = new FileOutputStream(file);
byte buffer [] = new byte[4*1024];
while((input.read(buffer))!=-1){
output.write(buffer);
}
output.flush();
}catch (Exception e)
e.printStackTrace();
}
finally {
try{
}catch (Exception e)
e.printStackTrace();
}
return file;
/* 函数返回-1:代表下载文件出错,0 :代表下载文件成功,1:代表文件存在*/
pulbic int downFile(String urlStr,String path ,String fileName){
InputStream inputStream = null;
try
{
FileUtils fileutils = new FileUtils();
if(fileutils.isFileExist(path+ fileName)){
return 1;
}
else{
inputStream = getInputStreamFormUrl(urlStr);
File resultFile = fileUtils.write2SDFormInput()
}
}
catch (Execption e)
{
e.printStore();
return -1;
}
}
需要用到了File 中的方法包括创建文件(createNewFile())创建目录(makedir())写入数据,判断文件是否存在等。
需要在AndroidManifest.xml 中写入uers访问网络和读写sdcard的权限
<uses-permission android:name ="android.permission.INTENET"/>
<uses-permission android:name ="android.permission.WRITE_EXTERNAL_STORAGE">
- android程序调试和访问网络进行下载
- 程序调试和网络调试
- Android通过网络调试程序
- Android通过网络调试程序
- Android中使用网络和服务器端程序进行数据交换
- OkHttp+Stetho+Chrome调试android网络访问
- Android之使用HttpURLConnection进行网络访问
- [网络]Unity中Http访问和下载
- android USB调试进行开发程序
- Android调试程序正确进行方式
- Android 使用 YouWave 模拟器 进行程序调试
- 通过有线网络调试进行Android应用调试
- 利用Stetho在Chrome进行Android网络和数据库的调试
- Android 中用 tcpdump 调试网络程序
- android允许访问网络和检测网络
- android 怎么进行调试程序 如何采用AndroidTestCase进行单元测试
- 大陆网络下如何快速使用Android SDK Manager进行联网更新和下载
- 程序调试指南1:使用CDB和NTSD进行调试
- java 自定义类型比较大小
- C#基于google earth的二次开发
- oracle split函数(自定义)
- C# 中panel的mousewheel事件触发
- 转:Java线程总结
- android程序调试和访问网络进行下载
- Android TextView当中设置超链接、颜色、字体
- UML用例图
- 用例图
- java初学者基础知识积累---(1)深拷贝和浅拷贝
- The Audacity of Hope
- FireFox 5.0 发布
- Enterprise Architect使用教程
- 曝光房屋租售合同诈骗6手段~~!!!!大家注意了·~~~