Hello
I am in need of your audio files are stored in binary form in the bank and then I put it in a text file.
I in another program request text file from the user and the information it contains text and audio file I use in program.
I your information in the text file saved with RandomAccessFile .
But my voice data stored in multiple lines.
I used my time to read files from readLine
So my file should be stored in a line.
Is there a way?
Grateful
String address="/"+getPackageName();
String card=Environment.getExternalStorageDirectory().toString();
File dir=new File(card+address);
if(!dir.exists())
dir.mkdir();
File f=new File(dir,edtNameFile.getText().toString()+".db");
RandomAccessFile r=new RandomAccessFile(dir+"/"+edtNameFile.getText().toString()+".db", "rw");
Cursor cur=dbh.GetAllWord();
startManagingCursor(cur);
if(cur.getCount()>0)
{
while(cur.moveToNext())
{
Cursor cur1=dbh.GetTranslate(cur.getInt(cur.getColumnIndex(COLUMN_ID_WORD)));
startManagingCursor(cur1);
if(cur1.getCount()>0)
{
edtTranslate=(cur1.getString(cur1.getColumnIndex(COLUMN_TRANSLATE)));
r.write(cur.getString(cur.getColumnIndex(COLUMN_ID_WORD)).getBytes());
r.write("@".getBytes());
r.write(cur.getString(cur.getColumnIndex(COLUMN_WORD)).getBytes());
r.write("@".getBytes());
r.write(edtTranslate.getBytes());
r.write("@".getBytes());
r.write(cur.getBlob(cur.getColumnIndex(COLUMN_Sound)));
r.write("@".getBytes());
r.write(cur.getString(cur.getColumnIndex(COLUMN_EXTENTION)).getBytes());
r.write("@".getBytes());
r.write('\n');
}
Format File Text:
ID@Word@Translate@Byte SoundFile@Extention SoudFile
Read File
BufferedReader buffRead=new BufferedReader(new FileReader(card) );
line=buffRead.readLine();
while((line=buffRead.readLine())!=null)
{
String[] dataFile=line.split("@");
DBHelperPersonalDB dbh=new DBHelperPersonalDB(AddDictionaryActivity.this,nameDataBase);
int ID=Integer.parseInt(dataFile[0]);
byte[] b=dataFile[3].getBytes();
dbh.InsertWord(ID,dataFile[1],dataFile[2],dataFile[3],dataFile[4]);
}
dbh.close();