2

I want to import .doc files from sdcard into my application and also in database of my application but when i am importing file text is not displaying correctly. It is showing symbols characters. How to change format from .doc to .txt

Nikki
  • 3,314
  • 13
  • 36
  • 59

2 Answers2

1

The .doc is a complex binary format and you will not be able to accomplish that easy. Feel free to read the specification here:

http://msdn.microsoft.com/en-us/library/cc313105(v=office.12).aspx

Fredrik Wallenius
  • 2,872
  • 2
  • 20
  • 15
  • i doesn't want to know about formats. I want to change format of .doc file into .txt file without changing file contents through android programming – Nikki Dec 22 '10 at 07:42
1

.doc is a Microsoft Word document file format which is not a plain text file. Its a binary file. So if you want to show only text, use a plain ASCII (.txt) file. If you want to show text with formatting or images then consider using HTML with WebView.

Mudassir
  • 13,031
  • 8
  • 59
  • 87
  • @Mudassir I would like to import .txt and .doc files and then show it in edit text – Nikki Dec 22 '10 at 08:14
  • 1
    You can of course import .txt files as they are plain text files, but this is not the case with .doc files. To do so you may definitely need some converter sort of thing. I don't know if MSWord doc converter is available for Android. However one approach can be, place the .doc files on a server and fetch the contents of these .doc files on your Android device through a web service. – Mudassir Dec 22 '10 at 08:19
  • But if i have downloaded .apk file of convertor than also how can i include its classes in my application – Nikki Dec 22 '10 at 08:25
  • As I know, we cannot use the classes of an .apk. If you downloaded a converter, then better search for some APIs for converter. – Mudassir Dec 22 '10 at 08:28
  • Then you should look for some other option. Can you tell me, exactly what do you want to implement? – Mudassir Dec 22 '10 at 11:33
  • ya sure..........i want to import .txt,.doc and .rtf files from sdcard into my application database and that document file is then shown in edit text. In edit text i can also update the text of the document in which is updated in database file only as on importing i have to make a copy of document file into the database. I am able to import .txt files but not .rtf and .doc files. And want to import that also. – Nikki Dec 22 '10 at 11:49
  • Hmmm... Cannot you create the database from imported files on the computer and then use that ready database on Android? – Mudassir Dec 22 '10 at 11:57
  • No, database is already created by me from android application. I just want to copy imported file into that database – Nikki Dec 22 '10 at 12:00
  • Are you sure, that there is no API available to read Word docs in Android? Look at this question http://stackoverflow.com/questions/2263951/read-microsoft-word-documents-into-plain-text-doc-docx-in-java – Mudassir Dec 22 '10 at 12:06
  • But this question also includes parsing and i am not using any parsing. And this ques. is not helping me – Nikki Dec 22 '10 at 12:13
  • If you want to use Word or RTF docs on Android device, I think you have to implement a parser. And If you don't to use parser then, one more solution is to convert them to plain text files on computer then use those plain text files on Android device. – Mudassir Dec 22 '10 at 12:17
  • ya...........thanks but i want word file to convert into plaintext on android application installed on android device without using parsers – Nikki Dec 22 '10 at 12:20
  • Buddy, I already told you, doc is a binary format hence can't be treated as plain (ASCII) text. You've to go either way. Let me know if you have any other option. – Mudassir Dec 22 '10 at 12:28
  • no.........................how could i implement parsing when there is no need and application not using it and how could i use it for changing format – Nikki Dec 22 '10 at 12:34
  • How could you say that parsing is not needed while there is no other option available? – Mudassir Dec 22 '10 at 12:38
  • I mean to say in my application parsing is not used. Then how could i do that. – Nikki Dec 22 '10 at 12:47
  • As I know, there is no other way than we've discussed above. – Mudassir Dec 22 '10 at 12:51