android,android-imageview,android-file,android-bitmap
Remove the line android:src="@drawable/android" from the XML layout. Since the image may vary every time, you need to use File file = new File("/sdcard/Images/test_image.jpg"); if(imgFile.exists()){ Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); ImageView image = (ImageView) findViewById(R.id.imageview1); image.setImageBitmap(bitmap); } ...
android,android-intent,android-file,android-sharing
This works when you trying to share with WhatsApp an audio file with whitespace: String filePath = "file:///sdcard/Download/example attachment.mp3"; Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath)); shareIntent.setType("audio/*"); startActivity(Intent.createChooser(shareIntent, "Share audio file")); ...
You are saving to MyMovieArray.srl but reading from MyMovieArray. Read also from MyMovieArray.srl File object should be created like this (both in write and read): File f = new File(getFilesDir(), "MyMovieArray.srl"); ...
android,filestream,android-file
Picasso is using the old cached image. To bypass the memory cache, use following: Picasso.with(context).load(newfile).skipMemoryCache().into(imageView); ...
android,file,base64,android-file
Base64 encoding takes 3 input bytes and converts them to 4 bytes. So if you have 100 Mb file that will end up to be 133 Mb in Base64. When you convert it to Java string (UTF-16) it size will be doubled. Not to mention that during conversion process at...
android,android-intent,android-file,mediastore
In Android all the data related to the media files is persisted in the MediaStore database. So having an URI you can query the MediaStore database and retrieve the filepath. Please refer to this question: Get filename and path from uri from mediastore...
android,arrays,file,android-file
Try the following code which may help you List<File> getListFiles(File parentDir) { ArrayList<File> inFiles = new ArrayList<File>(); File[] files = parentDir.listFiles(); for (File file : files) { if (file.isDirectory()) { inFiles.addAll(getListFiles(file)); } else { inFiles.add(file); } } return inFiles; } This will return you list of files under the directory...
android,android-intent,android-file
As I said in my comment, viewing a file requires downloading it. What you might mean, is that you don't want to store it. The problem is that the Android intent system doesn't offer this degree of flexibility, which is usually a good thing. You tell it to view a...
android,android-intent,android-file,android-fileprovider,android-implicit-intent
STEP 1 - Using an Implicit Intent: To choose a file from the device, you should use an implicit Intent Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType("*/*"); chooseFile = Intent.createChooser(chooseFile, "Choose a file"); startActivityForResult(chooseFile, PICKFILE_RESULT_CODE); STEP 2 - Getting the absolute file path: To get the file path from a Uri,...
android,android-intent,android-sdcard,android-file,android-videoview
Just update the lines in dispatchTakeVideoIntent() provide a proper path to create fileVideo first and make sure to call createNewFile() before putting in intent.
I have something similar in one of my applications: String filepath = getPath() + removeAccents(name); I did this function, that works on all APIS: public static String removeAccents(String s){ try{ s = s.toLowerCase(); if(VERSION.SDK_INT > Build.VERSION_CODES.FROYO){ s = Normalizer.normalize(s, Normalizer.Form.NFD); s = s.replaceAll("[^\\p{ASCII}]", ""); } else{ s = s.replace("á", "a").replace("é",...
android,android-sdcard,android-file,android-videoview
Turns out there were multiple problems with this. The first was that you can't use an OnClickListener with a VideoView, it must be an OnTouchListener. Then, I had to get an absolute path instead of just a simple getPath(). Then one more line, I had to call createNewFile() on my...
android,android-adapter,android-gridview,android-file
Have You tried imageLoader.clearMemoryCache(); and imageLoader.clearDiscCache(); ...
android,android-camera,android-file
you are using constructor new File(String path) timestamp+".jpg" isn't path I think... check this out: new File(Environment.getExternalStorageDirectory() .getAbsolutePath(), timestamp+".jpg"); ...
java,android,android-studio,android-file
openFileOutput(); needs a Context. You are calling it in an ArrayAdapter. It should be: // Define your context then use below code context.openFileOutput(); ...
android,android-file,pdfrenderer
Hi friend you need to store your pdf file in assets folder. Please check the stackoverflow question regarding this Read a pdf file from assets folder If you still have problem let me know...
android,performance,storage,android-file
You call getRootDirectory() to get the system directory. If you want the true root of all folders, it's always just "/". So just do new File("/");
java,android,android-intent,android-image,android-file
You don't necessarily need the absolute file path in order to copy the file, because you can open an InputStream from the Uri directly and copy the contents from that: void copyFileFromUri(Uri sourceUri, String destFilePath) throws IOException { InputStream in = getContentResolver().openInputStream(sourceUri); File outFile = new File(destFilePath); OutputStream out =...
The error No such file could be misleading - I guess it's not about your source file, but about your destination directory. You are providing JSch with a destination of <SPACE>/var/www/webimages/client/88/" - try to trim it. The nice thing about open source is that it's open source: you can take...
android,android-contentprovider,android-file
Try a BroadcastReceiver that has data in it. Send: Intent intent = new Intent("my.action.string"); intent.putExtra("on", true); sendBroadcast(intent); Receive: public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("my.action.string")){ boolean state = intent.getExtras().getBoolean("on"); } } Manifest: <receiver android:name=".MyReceiver" android:enabled="true"> <intent-filter> <action android:name="my.action.string" /> </intent-filter> </receiver> ...
android,google-glass,google-gdk,abstraction,android-file
You are referring, I presume, to this line: final File pictureFile = new File(picturePath); What they have done is created an instance of a File object from the file path where that image is stored. This File object is what they need to do some processing on the image. The...
java,android,inputstream,android-file,bufferedwriter
I want to read out a file in Android and get the content as a string. PDF files are not text files. They are binary files. Then I want to send it to a server Your Android application has very limited heap space. It will be better if you...
java,android,android-wifi,android-broadcast,android-file
You can do something like this: DeviceDetailFragment.java @Override protected String doInBackground(Void... params) { ServerSocket serverSocket = null; Socket client = null; DataInputStream inputstream = null; try { serverSocket = new ServerSocket(8988); client = serverSocket.accept(); inputstream = new DataInputStream(client.getInputStream()); String str = inputstream.readUTF(); serverSocket.close(); return str; } catch (IOException e) {...
android,android-5.0-lollipop,android-sdcard,android-file,documentfile
It's impossible. User should choose directory using android's file picker. The only way to get access to folder is using: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, 42); Because file is provided by Storage Access Framework DocumentsProvider. Actually it could return some Uri from 3-rd party app, which is not real...
android,file,file-io,android-file
I managed to solve my problem when I call the setResult and finish methods I did not realize the flow of the program is returned to my onCreate method which meant the rest of my method calls in onCreate was still being called and they require the templatePaths array. So...
android,broadcastreceiver,password-protection,android-file,appsettings
For ordinary users, put the file on internal storage (e.g., getFilesDir()). They have no access to those files. For users of rooted devices, there is no way to prevent them from deleting a file....
Try something like this. public void buttonClick(View v) { EditText txtEditor = (EditText) findViewById(R.id.editText); try { FileOutputStream fos = openFileOutput(STORETEXT, Context.MODE_PRIVATE); fos.write(txtEditor.getText().toString().getBytes()); txtEditor.setText(""); fos.close(); Toast.makeText(this, "Saved password", Toast.LENGTH_LONG).show(); } catch (Throwable t) { Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show(); } String contents = ""; try { FileInputStream fin = openFileInput(STORETEXT);...
android,database,aes,android-sqlite,android-file
getFilesDir gives you your /data/data/ - and you can then just access the databases/my_sql.db file directly. Be weary about hardcoding paths....
in the first error you're using a wrong path (I guess). Since the 4.4 version (I'm not sure) they changed the way to access to external devices. You should write: String fname=title+".pdf"; loc="/mnt/media_rw/sdcard"+"/"+fname; output=new FileOutputStream(loc); I think it is the right way. I defined the permissions in my manifest file...
android,file,outputstream,android-file,android-videoview
First of all, you should put fout.flush(); fout.close(); in a finally block after the catch section to ensure the file is always written. If you are looking at the USB connection via Windows Explorer, there is a delay due to caching probably(the file is actually present on disk but not...