BlackBerry平台文件目录访问
来源:互联网 发布:网络延迟多少正常 编辑:程序博客网 时间:2024/05/20 18:55
在BlackBerry SDK 5.0平台提供两种方式的文件目录访问:
- FileConnection - J2ME
- FilePicker - BlackBerry Native
J2ME方式是比较传统方式,本文介绍BlackBerry Native提供的FilePicker方式。FilePicker为文件访问目录提供界面,支持多种文件目录访问选项,比如设置起始文件目录和设置文件过滤等等。
范例如下:
创建FilePicker并显示文件目录:
final FilePicker filePicker = FilePicker.getInstance();
filePicker.show();
访问指定的文件目录:
String startPath = "file://store/home/user/documents"
filePicker.setPath(startPath);
设置过滤:
String filterString = "jpg"
filePicker.setFilter(filterString);
使用FilePicker运行截图如下:
文件目录访问源代码如下:
package com.rim.samples.device.ui.filepickerdemo;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.picker.*;
/** FieldChangeListener ButtonField.NEVER_DIRTY);
/**
* A sample application to demonstrate the FilePicker class
*/
public class FilePickerDemo extends UiApplication
{
/**
* Entry point for application
* @param args Command line arguments (not used)
*/
public static void main(String[] args)
{
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
FilePickerDemo app = new FilePickerDemo();
app.enterEventDispatcher();
}
/**
* Creates a new FilePickerDemo object
*/
public FilePickerDemo()
{
pushScreen(new FilePickerDemoScreen());
}
* MainScreen class for the FilePickerDemo application
*/
static class FilePickerDemoScreen extends MainScreen implements FilePicker.Listener,
{
private LabelField _labelField;
private FilePicker _filePicker;
private ButtonField _buttonField;
/**
* Creates a new FilePickerDemoScreen object
*/
FilePickerDemoScreen()
{
// Initialize screen
setTitle("File Picker Demo");
_buttonField = new ButtonField("Choose File", ButtonField.CONSUME_CLICK |
_buttonField.setChangeListener(this);
add(_buttonField);
_labelField = new LabelField();
add(_labelField);
// Get the FilePicker instance
_filePicker = FilePicker.getInstance();
// Make this class a file picker listener
_filePicker.setListener(this);
}
/**
* @see FilePicker.Listener#selectionDone(String)
*/
public void selectionDone(String selection)
{
if(selection != null && selection.length() > 0)
{
// Display the chosen file on the screen
_labelField.setText("File selected: " + selection);
}
}
/**
* @see FieldChangeListener#fieldChanged(Field, int)
*/
public void fieldChanged(Field field, int context)
{
if(field == _buttonField)
{
_filePicker.show();
}
}
}
}
- BlackBerry平台文件目录访问
- 访问文件目录,文件
- QT文件目录访问
- 访问文件和目录
- 访问文件目录dir
- 访问文件和目录
- BlackBerry开发平台常见问题
- BlackBerry平台获取手机号
- 文件或目录访问记录
- linux 访问目录及文件
- apche限制文件目录访问
- tomcat 允许访问目录文件
- linux目录文件权限访问
- BlackBerry平台发送短信实现
- Blackberry平台开发,教程,范例
- blackberry查找文件
- 为什么不能把BlackBerry开发项目deliverables目录下面的jar文件给第三方?
- Linux文件和目录访问权限设置
- MVC Model binder(complex object)
- 015 测试菜单兼测背景风格
- 首届 Google 暑期大学生博客分享大赛——2010 Andriod - Android 情
- 关于asp.net三种重定向方法的总结
- pku2002
- BlackBerry平台文件目录访问
- KTV娱乐会所兼职工资日结
- Lua脚本在C++下的舞步(一)
- 数组(Array)
- 注册博客
- linux 下三款监控网卡流量的软件iptraf iftop nload
- linux 下三款监控网卡流量的软件iptraf iftop nload
- linux 下三款监控网卡流量的软件iptraf iftop nload
- linux下java的安装和环境配置