如何与PhoneGap的电话簿检查文件的存在 [英] How to check a file's existence in phone directory with phonegap
本文介绍了如何与PhoneGap的电话簿检查文件的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写一个Android应用程序与PhoneGap的1.4.1和煎茶的下载和阅读PDF文件。如何检查文件是否存在于电话簿使用PhoneGap的两种方法,JavaScript或AJAX?
I'm writing an Android application with Phonegap 1.4.1 and Sencha that downloads and reads pdf files. How can I check whether the file exists in the phone directory using either phonegap methods, javascript or ajax?
推荐答案
您可以检查文件是否存在利用的PhoneGap的的FileReader对象。 您可以检查以下内容:
You could check if the file exists using the FileReader object from phonegap. You could check the following:
var reader = new FileReader();
var fileSource = <here is your file path>
reader.onloadend = function(evt) {
if(evt.target.result == null) {
// If you receive a null value the file doesn't exists
} else {
// Otherwise the file exists
}
};
// We are going to check if the file exists
reader.readAsDataURL(fileSource);
这篇关于如何与PhoneGap的电话簿检查文件的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文