草庐IT

GetFilesDir

全部标签

java - getFilesDir() 导致空指针异常

我正处于学习Java的早期阶段,但希望有人能解释我在这里做错了什么,大量的Google搜索让我头晕目眩。我一直在学习如何将ArrayList保存到文本文件然后获取详细信息的教程。我收到以下错误:-01-1019:00:37.09216897-16897/uk.co.c2digital.futurefotoE/AndroidRuntime:FATALEXCEPTION:mainProcess:uk.co.c2digital.futurefoto,PID:16897java.lang.RuntimeException:UnabletoinstantiateactivityComponent

java - 从 URI 或原始文件路径 [getExternalFilesDir(String type) vs getFilesDir()] 重新创建文件时,文件长度为 0

先了解一下背景知识:此应用会拍照并上传到Azureblob存储。使用getApplicationContext().getFilesDir();将图片存储在一个文件(内部存储)中要上传,我需要像这样调用uploadFromFile(..)函数:CloudBlockBlob.uploadFromFile(字符串路径);AzureSDK的uploadFromFile函数如下所示:publicvoiduploadFromFile(finalStringpath)throwsStorageException,IOException{uploadFromFile(path,null/*acces

android - 来自 getFilesDir() 的 FileProvider

Context.getFilesDir()对应的XML是什么?我当前的XML:文件创建:Filevideo=newFile(getFilesDir(),"movie.mp4");videoUri=FileProvider.getUriForFile(this,"my.package.name.provider",video); 最佳答案 是用于通过FileProvider从getFilesDir()提供文件的XML。 关于android-来自getFilesDir()的FileProvi

android - 如何将使用 MediaRecorder 录制的视频长度读取到通过 context.getFilesDir() 构建的私有(private)应用程序存储目录中?

我在读取使用MediaRecorder使用设备相机录制的视频文件的长度/持续时间时遇到了一个奇怪的问题。该文件被记录到应用程序的私有(private)存储目录​​中,该目录是这样设置的:mMediaRecorder.setOutputFile(context.getFilesDir()+"/recordings/webcam.3gpp");录制完成后,我尝试用这些方法读取视频的长度:方法一:MediaMetadataRetrievermediaMetadataRetriever=newMediaMetadataRetriever();mediaMetadataRetriever.set

android - 警告 : Do not hardcode "/data/"; use Context. getFilesDir().getPath() 代替

我开发了一个应用程序,在其中我将数据库从Assets文件夹复制到我的硬编码路径。所以eclipse给了我警告:Donothardcode"/data/";useContext.getFilesDir().getPath()instead我在谷歌搜索并找到了使用的答案:Context.getFilesDir().getPath();硬编码并非在所有设备上都有效,在某些设备上可能会出错或无法正常工作。但是通过执行上述操作,我遇到了错误。我的代码如下:privatefinalContextmyContext;在此处收到警告privatestaticStringDB_PATH="/data/d
12