Last active
May 17, 2018 08:30
-
-
Save bulentsiyah/1c639d427362cd10a35dd93bf7c2e816 to your computer and use it in GitHub Desktop.
Dosyayı Private olarak kaydetme -- Servis gizlice kaydediyor, MainActivity de daha önce kaydedilmişleri sıralıyoruz. -- http://www.bulentsiyah.com/dosyayi-gizli-baska-uyg-tarafindan-erisilemeyek-klasore-olarak-kaydetme-android/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is the difference between getDir and getFilesDir on Android? | |
getFilesDir() returns a File object to a directory that is private to your application only. | |
When you use openFileOutput(String, int), | |
the data you write is directly stored in this directory and is not accessible by any other application. | |
It holds your application files. | |
getDir() enables you to create any file or directory in the internal memory, | |
which is also accessible by other applications depending on the mode you create it. | |
openFileOutput(String, int) will not work with the output of this so you will have to use other means | |
of writing and reading files to deal with this directory or file. | |
This is more used for creating custom files other than files only used by your application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
File directory = getFilesDir(); | |
File[] files = directory.listFiles(); | |
Log.d("Files", "Size: "+ files.length); | |
for (int i = 0; i < files.length; i++) | |
{ | |
Log.d("Files", "FileName:" + files[i].getName()); | |
} | |
}catch (Exception exp){ | |
exp.toString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bunlar unutulmamalı | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onCreate() { | |
super.onCreate(); | |
try { | |
Date date = new Date(); | |
String stringDate = DateFormat.getDateTimeInstance().format(date); | |
String sd_temp = "/" + stringDate + "callrec.3gp"; | |
//prepareDirectory(getApplicationContext(),sd_temp); | |
// file = new File(dir_CallRecorder); | |
File dir = getFilesDir(); | |
rec = new MediaRecorder(); | |
rec.setAudioSource(MediaRecorder.AudioSource.MIC); | |
rec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); | |
rec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); | |
rec.setOutputFile(dir.getAbsoluteFile()+sd_temp); | |
rec.prepare(); | |
rec.start(); | |
} catch (Exception e) { | |
e.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment