将我通过应用程序创建的文件夹中的文件从电脑复制到平板电脑,这不可能吗?
编辑:在意识到我必须将事情公开后,可以这么说,这就是我尝试创建一个文件夹,当从我的电脑插入平板电脑并在那里复制内容时我可以看到:
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) ;
File theFile = new File(path+"/Portfolio/");
//if(!theFile.exists())
theFile.mkdir();
我注释掉了 if theFile.exists() 原因它总是返回 true。
所以现在我有了这个似乎可以工作的文件夹,没有抛出任何错误,并且应该创建该文件夹,事实上我正在使用 设备上的 Adao 文件管理器
浏览到此位置,它确实位于 /Pictures/Portfolio 下
,但是当我将其插入 Windows 计算机时,我看到 /Pictures 但下面没有文件夹,我只是失去它?
好的,
我从我的应用程序中在平板电脑上制作了这些小 DIR,以将客户端文件放入其中。我想我可以连接平板电脑并将文件从我的电脑复制到我的这些文件夹 已经做了。问题是,当我插入我的 acer iconia 时,当它显示出来并且我可以浏览一些文件时,它似乎是我使用 File.mkdir() 在应用程序中创建的文件夹;是这个路径:
/sdcard/Android/data/my.softwares.package.name/files/Pictures/somefolders
而我可以使用第 3 方文件浏览器应用程序来查看此文件夹确实存在我可以从 Windows 看出我只能浏览至:
/sdcard/Android/data
(如果我什至不确定)....真的是这样还是我错过了什么?我用来创建这些文件夹的代码是:
String p = Environment.DIRECTORY_PICTURES + "/" + s.getClient().getFirstName()+s.getClient().getLastName() + "/" + s.getPackage().getName() + (mSession.getSessionDate().getMonth()+1) + mSession.getSessionDate().getDate() + (mSession.getSessionDate().getYear()+1900);
File path = mContext.getExternalFilesDir(p);
if(!path.exists())
path.mkdir();
当我将平板电脑插入电脑时,这里似乎运气不佳,同样只能到达 Android/data
所以这是一个类似程序的组合,我想在设备上,用户可以将图片从他们的电脑复制到,然后创建该文件夹的同一个应用程序可以在图片全部复制完毕后读取该文件夹,所以我假设 Windows 能够读取上的所有内容,所以我错过了什么SD卡好像是假的?
EDIT: After realizing I have to make things public so to speak this is what I attempted to create a folder I could see when plugging the tablet in from my pc and copying stuff over there:
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) ;
File theFile = new File(path+"/Portfolio/");
//if(!theFile.exists())
theFile.mkdir();
I commented out the if theFile.exists() cause it was always returning true.
So now I have this folder that seems to work, no errors are thrown and the folder should be created in fact I am usingAdao File Manager
on the device to browse to this location it is indeed there under /Pictures/Portfolio
but when I plug it into my windows machine, i see /Pictures but no folders underneath it, am i just losing it?
Okay so
I have these little DIR is make on my tablet from my application, to put client files into. I thought I could just connect the tablet up and copy files from my PC to these folder I
had made. The thing is when I plug my acer iconia in, while it shows up and I can browse some files it seems the folder I made in the app using File.mkdir(); is this path:
/sdcard/Android/data/my.softwares.package.name/files/Pictures/somefolders
while I can use a 3rd party file browser app to see this folder does exsist as far as I can tell from windows i can only browse as far as:
/sdcard/Android/data
(if im even getting there not sure).... is this really the case or am I missing something? The code I use to create these folders is:
String p = Environment.DIRECTORY_PICTURES + "/" + s.getClient().getFirstName()+s.getClient().getLastName() + "/" + s.getPackage().getName() + (mSession.getSessionDate().getMonth()+1) + mSession.getSessionDate().getDate() + (mSession.getSessionDate().getYear()+1900);
File path = mContext.getExternalFilesDir(p);
if(!path.exists())
path.mkdir();
Seems no luck here when I plug my tablet into the pc, again only can go as far as Android/data
So this is for a portfolio like program, I want to create a folder on the device, users can copy pictures to from their pc, then the same app that created the folder can read this folder later on after the pictures have all been copied over, so what am I missing since my assumption of windows being able to read everything on the sdcard seems false?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已在应用程序的私有数据区域中创建了图片,因此无权访问它。这将是一个安全问题。
将数据保存到公共位置,例如 SD 卡。只需读取外部存储即可。
http://developer.android.com/guide/topics/data /data-storage.html#filesExternal
You have created the pictures in the private data area of your app and therefore do not have access to it. That would be a security problem.
Save the data to a public location like the sdcard. Just read up on external storage.
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal