Android saving the audio files into internal storage -


currently have created audio-recording android app. file saved @ external storage.

what if change method save internal storage context of mode_private

i have read android developers saving files have no idea how convert file instance byte array save file , load audio file

the below code save audio file

public void onclick(view view) throws exception {     if (count == 0) {          tbxrecordstatus.settext("record");         btnrecord.settext("stop record");          toast.maketext(mainactivity.this, "recording starts",                 toast.length_short).show();         dateinstring = new simpledateformat("yyyy-mm-dd-hh-mm-ss").format(                 new date()).tostring();         string filename = "tvssssd_" + dateinstring + " record.3gp";          sdcardpath = environment.getexternalstoragedirectory();         mydatapath = new file(sdcardpath.getabsolutepath()                 + "/.my recordings");          // mydir = context.getdir("media", context.mode_private);         if (!mydatapath.exists())             mydatapath.mkdir();           audiofile = new file(mydatapath + "/" + filename);          log.d("path", mydatapath.getabsolutepath());         // file filewithinmydir = new file(mydir, filename);         // audiofile = filewithinmydir;         // fileoutputstream out = new fileoutputstream(filewithinmydir);          recorder = new mediarecorder();         recorder.reset();         recorder.setaudiosource(mediarecorder.audiosource.mic);         recorder.setoutputformat(mediarecorder.outputformat.three_gpp);         recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb);         recorder.setaudioencodingbitrate(16);         recorder.setaudiosamplingrate(44100);          recorder.setoutputfile(audiofile.getabsolutepath());          recorder.prepare();          recorder.start();          count++;      } else {          tbxrecordstatus.settext("stop");         btnrecord.settext("start record");         toast.maketext(mainactivity.this, "recording stops",                 toast.length_short).show();         if (recorder != null) {             recorder.stop();             recorder.release();              recorder = null;          } else {             tbxrecordstatus.settext("warning!");             toast.maketext(mainactivity.this, "record first",                     toast.length_short).show();         }         count = 0;     } } 

the below code load audio file

recordlist = new arraylist<string>();     file directory = environment.getexternalstoragedirectory();     file = new file(directory + "/my recordings");     file list[] = file.listfiles();     (int = 0; < list.length; i++) {         recordlist.add(list[i].getname());     }      collections.sort(recordlist, collections.reverseorder());      listview = (listview) findviewbyid(r.id.listview);     arrayadapter<string> adapter = new arrayadapter<string>(this,             android.r.layout.simple_list_item_1, android.r.id.text1,             recordlist);       listview.setadapter(adapter);      listview.settextfilterenabled(true);      listview.setonitemclicklistener(new onitemclicklistener() {          @override         public void onitemclick(adapterview<?> parent, view view, int position,                 long arg3) {             // todo auto-generated method stub               string product = ((textview) view).gettext().tostring();             string fullpathaudio = file.getabsolutepath() + "/" + product;              file resultfile = new file(fullpathaudio);              intent intent = new intent();             intent.setaction(android.content.intent.action_view);             intent.setdataandtype(uri.fromfile(resultfile), "audio/*");             startactivity(intent);         }     }); 

use getfilesdir()

 sdcardpath = getfilesdir();         mydatapath = new file(sdcardpath.getabsolutepath()                 + "/.my recordings");          // mydir = context.getdir("media", context.mode_private);         if (!mydatapath.exists())             mydatapath.mkdir();           audiofile = new file(mydatapath + "/" + filename); 

for more see using internal storage


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -