Click here to Skip to main content
15,894,241 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Java
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');

		}//end if
Format File Text:		
ID@Word@Translate@Byte SoundFile@Extention SoudFile

Read File
Java
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();
Posted
Updated 30-Nov-14 2:24am
v4
Comments
OriginalGriff 30-Nov-14 6:00am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
And that makes little sense at all at present!
Use the "Improve question" widget to edit your question and provide better information.
Member 10496892 30-Nov-14 6:24am    
Excuse me
OriginalGriff 30-Nov-14 7:08am    
Stop and think for a minute: we can't see your code.
So we have no idea how you are saving the data - and "random access file" and "in text file" doesn't help us. and "stored in multiple lines" tells us nothing either.

Take a step back from the problem, and try to forget everything you know about it and your solution. Now read the question again, and see if you can solve it - because we can't.
We need to know how you are saving the data: which means we need your code.
We need to know what you expected to get, and exactly what you did get - a sample of the data would help.
And we need to know what is wrong with what you do get - and how you "know" it's wrong, because we can't see what you do: we only get the word your write here to work from.

Would you expect a garage to be able to fix your car if you phone them, say "It don't work" and put the phone down? :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900